Indents for fill grid (started)

This commit is contained in:
Anton 2021-03-02 15:58:21 +01:00
parent d81383eb25
commit 436c157dc6
2 changed files with 157 additions and 7 deletions

View File

@ -10,7 +10,6 @@ Public Class Grating_Fill
Public Shared Sub Calculate_Grid()
Get_SingleGratingMaxDimensions()
gratingDimensions.Clear()
gratingDimensions.Columns.Clear()
gratingDimensions.Columns.Add("INDEX", GetType(Integer))
@ -19,22 +18,22 @@ Public Class Grating_Fill
gratingDimensions.Columns.Add("WIDTH", GetType(Integer))
gratingDimensions.Columns.Add("LENGTH", GetType(Integer))
If (Data.gratingL / maxSingleLength) Mod 1 = 0 Then
numOfHorizontal = Data.gratingL / maxSingleLength
Else
numOfHorizontal = Math.Floor(Data.gratingL / maxSingleLength) + 1
End If
numOfVertical = Math.Floor(Data.gratingW / maxSingleWidth) + 1
minLength = (Math.Floor((Data.gratingL / 100) / numOfHorizontal) + 1) * 100 'Hantera längder med mer än 100mm mellan typ 1600-1800
If (Data.gratingW / maxSingleWidth) Mod 1 = 0 Then
numOfVertical = Data.gratingW / maxSingleWidth
Else
numOfVertical = Math.Floor(Data.gratingW / maxSingleWidth) + 1
End If
minLength = (Math.Floor((Data.gratingL / 100) / numOfHorizontal) + 1) * 100
If minLength > 1600 AndAlso (minLength / 100) Mod 2 = 1 Then
minLength += 100
End If
If minLength > maxSingleLength Then
minLength = maxSingleLength
End If

View File

@ -56,6 +56,8 @@ Public Class Model_3D_Fill
Dim designTable = designModel.selectDesign("*")
designName = designTable.rows(0)("designName")
groupClass.InstantiateGroup(designName, grNr, "START")
Recess_Indent()
End Sub
Private Shared Sub Inst_Recesses(parentID As Integer, gratingParameters As DataRow, recessDR As DataRow)
@ -182,4 +184,153 @@ Public Class Model_3D_Fill
End If
End Sub
Private Shared Sub Recess_Indent()
Dim swApp As SldWorks.SldWorks
swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks)
Dim boolstatus As Boolean
Dim AssemblyExtension As SldWorks.ModelDocExtension
Dim Assembly = swApp.ActiveDoc
Dim SelMgr = Assembly.SelectionManager()
AssemblyExtension = Assembly.Extension
Dim sldata = SelMgr.CreateSelectData
Dim partDT As New DataTable
partDT = partModel.selectPart("*")
Dim recessParentName As String = partDT.Rows(Grating_Fill.numOfHorizontal * (Grating_Fill.numOfVertical - 1))("partName")
Dim recessParts = partDT.Select("parentName = '" & recessParentName & "'")
For i = 0 To recessParts.Count - 1
Dim tempList As List(Of Integer) = Data.recessData.Rows(i)("GRATINGS")
For j = 0 To tempList.Count - 1
Assembly.ClearSelection2(True)
Dim gratingPartName As String = partDT.Rows(Data.recessData.Rows(i)("GRATINGS")(j))("partName")
boolstatus = AssemblyExtension.SelectByID2(gratingPartName & "-1@" & designName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
Dim gratingPart = SelMgr.GetSelectedObject6(1, -1)
Assembly.EditPart
Dim components = Assembly.GetComponents(True)
Dim indexGrating As Integer
For k = 0 To components.Length - 1
If components(k).Name2 = gratingPartName & "-1" Then
indexGrating = k
Exit For
End If
Next
Dim gratingBodies = components(indexGrating).GetBodies2(0)
Dim recessPartName As String = recessParts(i)("partName")
boolstatus = AssemblyExtension.SelectByID2(recessPartName & "-1@" & designName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
Dim recessPart = SelMgr.GetSelectedObject6(1, -1)
Dim indexRecess As Integer
For k = 0 To components.Length - 1
If components(k).Name2 = recessPartName & "-1" Then
indexRecess = k
Exit For
End If
Next
Dim recessBodies = components(indexRecess).GetBodies2(0)
For k = 0 To gratingBodies.Length - 1
sldata.Mark = 1
Dim bodyName As String = gratingBodies(k).Name & "@" & gratingPartName & "-1@" & designName
boolstatus = AssemblyExtension.SelectByID2(bodyName, "SOLIDBODY", 0, 0, 0, True, 1, Nothing, 0)
sldata.Mark = 4
Dim indexBody As Integer
For l = 0 To recessBodies.Length - 1
If recessBodies(l).Name = "Boss-Extrude1" Then
indexBody = l
Exit For
End If
Next
Dim recessFace = recessBodies(indexBody).GetFirstFace
recessFace.Select4(True, sldata)
Assembly.FeatureManager.InsertIndent(0.01, 0, False, True, True, False)
Assembly.ClearSelection2(True)
Next
Assembly.EditAssembly
Next
Next
' Grating part
'Dim gratingPartName As String = partDT.Rows(0)("partName")
'boolstatus = AssemblyExtension.SelectByID2(gratingPartName & "-1@" & designName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
' Dim gratingPart = SelMgr.GetSelectedObject6(1, -1)
'Assembly.EditPart
' Dim components = Assembly.GetComponents(True)
'Dim indexGrating As Integer
'For i = 0 To components.Length - 1
' If components(i).Name2 = gratingPartName & "-1" Then
' indexGrating = i
' Exit For
' End If
'Next
'Dim gratingBodies = components(indexGrating).GetBodies2(0)
'' Dim recessParts = partDT.Select("parentName = '" & gratingPartName & "'")
''Dim recessPartName As String
'For i = 0 To recessParts.Count - 1
' 'Assembly.ClearSelection2(True)
' ' Recess part
' 'recessPartName = recessParts(i)("partName")
' ' boolstatus = AssemblyExtension.SelectByID2(recessPartName & "-1@" & designName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
' 'Dim recessPart = SelMgr.GetSelectedObject6(1, -1)
' 'Dim indexRecess As Integer
' 'For j = 0 To components.Length - 1
' ' If components(j).Name2 = recessPartName & "-1" Then
' ' indexRecess = j
' ' Exit For
' ' End If
' 'Next
' 'Dim recessBodies = components(indexRecess).GetBodies2(0)
' For j = 0 To gratingBodies.Length - 1
' sldata.Mark = 1
' Dim bodyName As String = gratingBodies(j).Name & "@" & gratingPartName & "-1@" & designName
' boolstatus = AssemblyExtension.SelectByID2(bodyName, "SOLIDBODY", 0, 0, 0, True, 1, Nothing, 0)
' sldata.Mark = 4
' Dim indexBody As Integer
' For k = 0 To recessBodies.Length - 1
' If recessBodies(k).Name = "Boss-Extrude1" Then
' indexBody = k
' Exit For
' End If
' Next
' Dim recessFace = recessBodies(indexBody).GetFirstFace
' recessFace.Select4(True, sldata)
' Assembly.FeatureManager.InsertIndent(0.01, 0, False, True, True, False)
' Assembly.ClearSelection2(True)
' Next
'Next
End Sub
End Class