Start of creating fill function drawings
This commit is contained in:
parent
0055802527
commit
2b69ed463a
|
|
@ -270,6 +270,7 @@
|
|||
Dim dashPen As Pen = New Pen(Color.DarkGray, 1)
|
||||
dashPen.DashPattern = {6, 4}
|
||||
|
||||
'Vertical lines
|
||||
Dim singleLength As Integer = Grating_Fill.minLength / Data.scaleDiff
|
||||
For i = 0 To Grating_Fill.numOfHorizontal - 2
|
||||
Dim x As Integer
|
||||
|
|
@ -280,6 +281,7 @@
|
|||
g.DrawLine(dashPen, x, y1, x, y2)
|
||||
Next
|
||||
|
||||
'Horizontal lines
|
||||
Dim singleWidth As Integer = Grating_Fill.maxSingleWidth / Data.scaleDiff
|
||||
For i = 0 To Grating_Fill.numOfVertical - 2
|
||||
Dim y As Integer
|
||||
|
|
|
|||
|
|
@ -244,10 +244,12 @@ Public Class Individual
|
|||
If AppForm.fillMode Then
|
||||
Grating_Fill.Calculate_Grid()
|
||||
|
||||
Model_3D_Fill.BuildGrid()
|
||||
Multiple_Drawing.Create_Models_For_Drawing() ' Ska flyttas till sist i if satsen
|
||||
|
||||
Multiple_3D.BuildGrid()
|
||||
Else
|
||||
Model_3D.BuildGrating()
|
||||
Drawing.Create_Model_For_Drawing()
|
||||
Individual_3D.BuildGrating()
|
||||
Individual_Drawing.Create_Model_For_Drawing()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
Imports XCCLibrary
|
||||
Imports SldWorks
|
||||
|
||||
Public Class Model_3D
|
||||
Public Class Individual_3D
|
||||
Private Shared gratingParameters As DataRow
|
||||
Private Shared designName As String
|
||||
Public Shared partDT As New DataTable
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
Imports SldWorks
|
||||
Public Class Drawing
|
||||
Public Class Individual_Drawing
|
||||
Private Shared sideCounter As Integer()
|
||||
|
||||
Public Shared Sub Create_Model_For_Drawing()
|
||||
|
|
@ -7,7 +7,7 @@ Public Class Individual_Frame_Drawing
|
|||
Dim model As ModelDoc2
|
||||
Dim assembly As IAssemblyDoc
|
||||
Dim longstatus As Integer
|
||||
frameComponents = Model_3D.partDT.Select("partType = 'frame_l_straight'")
|
||||
frameComponents = Individual_3D.partDT.Select("partType = 'frame_l_straight'")
|
||||
|
||||
For i = 0 To Individual_Frame_3D.cuttingList.Count - 1
|
||||
model = swApp.NewDocument("C:\ProgramData\SolidWorks\SOLIDWORKS 2020\templates\Assembly.asmdot", 0, 0, 0)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,18 @@
|
|||
Imports XCCLibrary
|
||||
Imports SldWorks
|
||||
|
||||
Public Class Model_3D_Fill
|
||||
Public Class Multiple_3D
|
||||
Private Shared gratingParameters As DataRow
|
||||
Private Shared designName As String
|
||||
Public Shared Sub BuildGrid()
|
||||
Dim pointTable As DataTable
|
||||
pointTable = Data.gratingPoints
|
||||
Dim pointTable1 As DataTable
|
||||
pointTable1 = Data.grossAreaPoints
|
||||
|
||||
|
||||
|
||||
|
||||
Dim exportTable As DataTable
|
||||
exportTable = User_Input.Create_ExportTable()
|
||||
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
Imports SldWorks
|
||||
Public Class Multiple_Drawing
|
||||
|
||||
Public Shared Sub Create_Models_For_Drawing()
|
||||
Dim gratingsPointsDS As DataSet = Create_GreatingPoints()
|
||||
|
||||
Dim gratingHeight As Decimal = User_Input.gratingHeight / 1000
|
||||
|
||||
Dim swApp As SldWorks.SldWorks
|
||||
swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks)
|
||||
Dim Model As ModelDoc2
|
||||
Dim RootPoint(2) As Double
|
||||
Dim Normal(2) As Double
|
||||
swApp.UserControl = True
|
||||
|
||||
Dim swSkMgr As SketchManager
|
||||
Dim longstatus As Integer
|
||||
Dim boolstatus As Boolean
|
||||
Dim swModelDocExtension As ModelDocExtension
|
||||
Dim status As Boolean
|
||||
Dim swFeatureMgr As FeatureManager
|
||||
Dim swFeature As Feature
|
||||
Dim iPart As PartDoc
|
||||
|
||||
Dim numOfGratings As Integer = Grating_Fill.numOfVertical * Grating_Fill.numOfHorizontal
|
||||
|
||||
For i = 0 To numOfGratings - 1
|
||||
Model = swApp.NewDocument("C:\ProgramData\SOLIDWORKS\SOLIDWORKS 2020\templates\part.prtdot", 0, 0, 0)
|
||||
|
||||
swSkMgr = Model.SketchManager
|
||||
swSkMgr.InsertSketch(True)
|
||||
boolstatus = Model.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
|
||||
Model.ClearSelection2(True)
|
||||
|
||||
For Each DR As DataRow In gratingsPointsDS.Tables(i).Rows
|
||||
Dim skPoint As SketchPoint
|
||||
Dim pX = DR("X")
|
||||
Dim pY = DR("Y")
|
||||
skPoint = swSkMgr.CreatePoint(pX, pY, 0)
|
||||
Next
|
||||
|
||||
For Each DR1 As DataRow In gratingsPointsDS.Tables(i).Rows
|
||||
Dim skLine As SketchLine
|
||||
Dim rowIndex = gratingsPointsDS.Tables(i).Rows.IndexOf(DR1)
|
||||
Dim DR2 As DataRow
|
||||
|
||||
Try
|
||||
DR2 = gratingsPointsDS.Tables(i).Rows(rowIndex + 1)
|
||||
Catch ex As Exception
|
||||
DR2 = gratingsPointsDS.Tables(i).Rows(0)
|
||||
End Try
|
||||
|
||||
Dim pX1 = DR1("X")
|
||||
Dim pY1 = DR1("Y")
|
||||
Dim pX2 = DR2("X")
|
||||
Dim pY2 = DR2("Y")
|
||||
|
||||
skLine = swSkMgr.CreateLine(pX1, pY1, 0, pX2, pY2, 0)
|
||||
Next
|
||||
|
||||
swSkMgr.InsertSketch(True)
|
||||
|
||||
swModelDocExtension = Model.Extension
|
||||
status = swModelDocExtension.SelectByID2("Sketch1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
|
||||
|
||||
swFeatureMgr = Model.FeatureManager
|
||||
swFeature = swFeatureMgr.FeatureExtrusion3(True, False, False, 0, 0, gratingHeight, 0, False, False, False, False, 0, 0, False, False, False, False, True, True, True, 0, 0, False)
|
||||
|
||||
|
||||
' MIddle points if needed
|
||||
|
||||
|
||||
Model.ClearSelection2(True)
|
||||
boolstatus = Model.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
|
||||
Model.FeatureManager.InsertRefPlane(8, gratingHeight, 0, 0, 0, 0)
|
||||
|
||||
iPart = swApp.ActiveDoc
|
||||
Dim newName As String
|
||||
newName = Settings.folderPaths("object_" & Data.objectNum & "_models3D_gratings_sw_support") & "\simplified_grating_" & i + 1 & ".SLDPRT"
|
||||
|
||||
|
||||
' Title head data
|
||||
|
||||
|
||||
longstatus = iPart.SaveAs3(newName, 0, 0)
|
||||
swApp.CloseDoc(newName)
|
||||
Next
|
||||
|
||||
' --- Assembly ---
|
||||
Dim assembly As IAssemblyDoc
|
||||
Model = swApp.NewDocument("C:\ProgramData\SolidWorks\SOLIDWORKS 2020\templates\Assembly.asmdot", 0, 0, 0)
|
||||
assembly = Model
|
||||
|
||||
Dim compNames(numOfGratings - 1) As String
|
||||
Dim coordNames(numOfGratings - 1) As String
|
||||
Dim transMatrix As Object = Nothing
|
||||
For i = 0 To numOfGratings - 1
|
||||
compNames(i) = Settings.folderPaths("object_" & Data.objectNum & "_models3D_gratings_sw_support") & "\simplified_grating_" & i + 1 & ".SLDPRT"
|
||||
coordNames(i) = ""
|
||||
Next
|
||||
|
||||
Dim assemComps As Object
|
||||
assemComps = assembly.AddComponents3((compNames), (transMatrix), (coordNames))
|
||||
|
||||
longstatus = Model.SaveAs3(Settings.folderPaths("object_" & Data.objectNum & "_models3D_gratings_sw_support") & "\simplified_grating_assembly.SLDASM", 0, 0)
|
||||
End Sub
|
||||
|
||||
Private Shared Function Create_GreatingPoints()
|
||||
Dim pointsDS As New DataSet
|
||||
|
||||
Dim numOfGratings As Integer = Grating_Fill.numOfVertical * Grating_Fill.numOfHorizontal
|
||||
|
||||
For i = 0 To numOfGratings - 1
|
||||
Dim pointsDT As New DataTable
|
||||
pointsDT.Columns.Add("NAME", GetType(String))
|
||||
pointsDT.Columns.Add("TYPE", GetType(String))
|
||||
pointsDT.Columns.Add("X", GetType(Double))
|
||||
pointsDT.Columns.Add("Y", GetType(Double))
|
||||
|
||||
' --- Determine grossArea points ----
|
||||
Dim pX(3) As Double
|
||||
Dim pY(3) As Double
|
||||
|
||||
Dim columnNum As Integer = (i + Grating_Fill.numOfHorizontal) Mod Grating_Fill.numOfHorizontal
|
||||
If columnNum <> (Grating_Fill.numOfHorizontal - 1) Then
|
||||
' Columnn: alla utom sista
|
||||
pX(0) = Data.grossAreaPoints.Rows(0)("X") + Grating_Fill.minLength * columnNum / 1000
|
||||
pX(1) = pX(0) + Grating_Fill.minLength / 1000
|
||||
pX(2) = pX(1)
|
||||
pX(3) = pX(0)
|
||||
Else
|
||||
' Column: sista
|
||||
pX(0) = Data.grossAreaPoints.Rows(0)("X") + Grating_Fill.minLength * columnNum / 1000
|
||||
pX(1) = Data.grossAreaPoints.Rows(1)("X")
|
||||
pX(2) = pX(1)
|
||||
pX(3) = pX(0)
|
||||
End If
|
||||
|
||||
Dim rowNum As Integer = Math.Floor(i / Grating_Fill.numOfHorizontal)
|
||||
If rowNum < Grating_Fill.numOfVertical - 2 Then
|
||||
' Row: alla utom sista och näst sista
|
||||
pY(0) = Data.grossAreaPoints.Rows(0)("Y") - Grating_Fill.maxSingleWidth * rowNum / 1000
|
||||
pY(1) = pY(0)
|
||||
pY(2) = pY(0) - Grating_Fill.maxSingleWidth / 1000
|
||||
pY(3) = pY(2)
|
||||
ElseIf rowNum < Grating_Fill.numOfVertical - 1 Then
|
||||
' Row: Näst sista
|
||||
pY(0) = Data.grossAreaPoints.Rows(0)("Y") - Grating_Fill.maxSingleWidth * rowNum / 1000
|
||||
pY(1) = pY(0)
|
||||
If Grating_Fill.widthRevNeeded = True Then
|
||||
pY(2) = pY(0) - Grating_Fill.revWidth / 1000
|
||||
Else
|
||||
pY(2) = pY(0) - Grating_Fill.maxSingleWidth / 1000
|
||||
End If
|
||||
pY(3) = pY(2)
|
||||
Else
|
||||
' Row: Sista
|
||||
If Grating_Fill.widthRevNeeded = True Then
|
||||
pY(0) = Data.grossAreaPoints.Rows(0)("Y") - Grating_Fill.maxSingleWidth * (rowNum - 1) / 1000 - Grating_Fill.revWidth / 1000
|
||||
Else
|
||||
pY(0) = Data.grossAreaPoints.Rows(0)("Y") - Grating_Fill.maxSingleWidth * rowNum / 1000
|
||||
End If
|
||||
pY(1) = pY(0)
|
||||
pY(2) = Data.grossAreaPoints.Rows(3)("Y")
|
||||
pY(3) = pY(2)
|
||||
End If
|
||||
|
||||
For j = 0 To 3
|
||||
Dim DR As DataRow = pointsDT.NewRow()
|
||||
DR("NAME") = "GA_" & j + 1
|
||||
DR("TYPE") = "GA"
|
||||
DR("X") = pX(j)
|
||||
DR("Y") = pY(j)
|
||||
|
||||
pointsDT.Rows.Add(DR)
|
||||
Next
|
||||
|
||||
' --- Add recess points ---
|
||||
|
||||
|
||||
|
||||
|
||||
pointsDT.TableName = "Grating " & i & " - C" & columnNum & " R" & rowNum
|
||||
pointsDS.Tables.Add(pointsDT)
|
||||
Next
|
||||
|
||||
Return pointsDS
|
||||
End Function
|
||||
End Class
|
||||
|
|
@ -119,11 +119,12 @@
|
|||
<Compile Include="Recess Functions\Corner_Rectangle.vb" />
|
||||
<Compile Include="Recess Functions\Middle_Rectangle.vb" />
|
||||
<Compile Include="Recess Functions\Side_Rectangle.vb" />
|
||||
<Compile Include="SolidWorks\Drawing.vb" />
|
||||
<Compile Include="SolidWorks\Individual_Drawing.vb" />
|
||||
<Compile Include="SolidWorks\Individual_Frame_3D.vb" />
|
||||
<Compile Include="SolidWorks\Individual_Frame_Drawing.vb" />
|
||||
<Compile Include="SolidWorks\Model_3D.vb" />
|
||||
<Compile Include="SolidWorks\Model_3D_Fill.vb" />
|
||||
<Compile Include="SolidWorks\Individual_3D.vb" />
|
||||
<Compile Include="SolidWorks\Multiple_3D.vb" />
|
||||
<Compile Include="SolidWorks\Multiple_Drawing.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="GUI\AppForm.resx">
|
||||
|
|
|
|||
Loading…
Reference in New Issue