Angle recess works for fill grid

This commit is contained in:
Anton 2021-03-04 14:50:40 +01:00
parent 6a1a75fab2
commit e2fceeac69
3 changed files with 179 additions and 80 deletions

Binary file not shown.

View File

@ -178,6 +178,37 @@ Public Class Grating_Fill
Data.recessData.Rows(k)("GRATINGS") = tempList Data.recessData.Rows(k)("GRATINGS") = tempList
Next Next
Dim tempList2 As New List(Of Integer)
Try
tempList2 = Data.recessData.Rows(k)("GRATINGS")
Catch ex As Exception
End Try
Dim gratingIndex2 As Integer
If Data.recessData.Rows(k)("CORNER") = 1 Then
gratingIndex2 = 0
ElseIf Data.recessData.Rows(k)("CORNER") = 2 Then
gratingIndex2 = numOfHorizontal - 1
ElseIf Data.recessData.Rows(k)("CORNER") = 3 Then
gratingIndex2 = numOfHorizontal * numOfVertical - 1
Else
gratingIndex2 = numOfHorizontal * (numOfVertical - 1)
End If
Dim indexNotAdded2 As Boolean = True
For j = 0 To tempList2.Count - 1
If gratingIndex2 = tempList2(j) Then
indexNotAdded2 = False
Exit For
End If
Next
If indexNotAdded2 Then
tempList2.Add(gratingIndex2)
End If
Data.recessData.Rows(k)("GRATINGS") = tempList2
End If End If
Next Next
End Sub End Sub

View File

@ -223,7 +223,7 @@ Public Class Model_3D_Fill
Assembly.ClearSelection2(True) Assembly.ClearSelection2(True)
For k = 0 To gratingBodies.Length - 1 For k = 0 To gratingBodies.Length - 1
If gratingBodies(k).Name <> "HorizontalSplitBody" Then If gratingBodies(k).Name <> "HorizontalSplitBody" AndAlso gratingBodies(k).Name <> "VerticalSplitBody" Then
Dim bodyName As String = gratingBodies(k).Name & "@" & gratingPartName & "-1@" & designName Dim bodyName As String = gratingBodies(k).Name & "@" & gratingPartName & "-1@" & designName
boolstatus = AssemblyExtension.SelectByID2(bodyName, "SOLIDBODY", 0, 0, 0, True, 2, Nothing, 0) boolstatus = AssemblyExtension.SelectByID2(bodyName, "SOLIDBODY", 0, 0, 0, True, 2, Nothing, 0)
End If End If
@ -268,7 +268,6 @@ Public Class Model_3D_Fill
End If End If
Next Next
Dim recessPartName As String = recessParts(i)("partName") Dim recessPartName As String = recessParts(i)("partName")
boolstatus = AssemblyExtension.SelectByID2(recessPartName & "-1@" & designName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0) boolstatus = AssemblyExtension.SelectByID2(recessPartName & "-1@" & designName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
Dim recessPart = SelMgr.GetSelectedObject6(1, -1) Dim recessPart = SelMgr.GetSelectedObject6(1, -1)
@ -309,89 +308,63 @@ Public Class Model_3D_Fill
Assembly.EditAssembly Assembly.EditAssembly
Next Next
For j = 0 To tempList.Count - 2
Assembly.ClearSelection2(True) Assembly.ClearSelection2(True)
Dim recessPartName As String = recessParts(i)("partName") Dim recessPartName2 As String = recessParts(i)("partName")
boolstatus = AssemblyExtension.SelectByID2(recessPartName & "-1@" & designName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0) boolstatus = AssemblyExtension.SelectByID2(recessPartName2 & "-1@" & designName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
Dim recessPart = SelMgr.GetSelectedObject6(1, -1) Dim recessPart2 = SelMgr.GetSelectedObject6(1, -1)
Assembly.EditPart Assembly.EditPart
Dim gratingPartName As String = partDT.Rows(Data.recessData.Rows(i)("GRATINGS")(j))("partName") Dim indexRecess2 As Integer
For k = 0 To components.Length - 1
If components(k).Name2 = recessPartName2 & "-1" Then
indexRecess2 = k
Exit For
End If
Next
For j = 0 To Grating_Fill.numOfVertical * Grating_Fill.numOfHorizontal
For k = 1 To 2
Dim gratingPartName As String = partDT.Rows(j)("partName")
Dim indexGrating As Integer Dim indexGrating As Integer
For k = 0 To components.Length - 1 For l = 0 To components.Length - 1
If components(k).Name2 = gratingPartName & "-1" Then If components(l).Name2 = gratingPartName & "-1" Then
indexGrating = k indexGrating = l
Exit For Exit For
End If End If
Next Next
Dim splitBodyName As String
Dim indexRecess As Integer If k = 1 Then
For k = 0 To components.Length - 1 splitBodyName = "VerticalSplitBody"
If components(k).Name2 = recessPartName & "-1" Then
indexRecess = k
Exit For
End If
Next
Dim recessBodies = components(indexRecess).GetBodies2(0)
Dim recessBodyIndex As Integer
For k = 0 To recessBodies.Length - 1
If recessBodies(k).Name = "Boss-Extrude2" Then
recessBodyIndex = k
Exit For
End If
Next
Dim recessBody = recessBodies(recessBodyIndex)
If Math.Abs(tempList(0) - tempList(1)) = 1 Then
'Plane split
Dim planeName As String = "VerticalSplitPlane@" & gratingPartName & "-1@" & designName
boolstatus = AssemblyExtension.SelectByID2(planeName, "PLANE", 0, 0, 0, True, 0, Nothing, 0)
Dim RefPlane As Object
RefPlane = Assembly.FeatureManager.InsertRefPlane(4, 0, 0, 0, 0, 0)
Assembly.ClearSelection2(True)
Dim vResultingBodies As Object
vResultingBodies = Assembly.FeatureManager.PreSplitBody()
Dim bodyOrigins As Object
Dim splitFeat As SldWorks.Feature
splitFeat = Assembly.FeatureManager.PostSplitBody(vResultingBodies, False, bodyOrigins, "")
Assembly.ClearSelection2(True)
gratingPartName = partDT.Rows(Data.recessData.Rows(i)("GRATINGS")(j + 1))("partName")
planeName = "VerticalSplitPlane@" & gratingPartName & "-1@" & designName
boolstatus = AssemblyExtension.SelectByID2(planeName, "PLANE", 0, 0, 0, True, 0, Nothing, 0)
Dim RefPlane2 As Object
RefPlane2 = Assembly.FeatureManager.InsertRefPlane(4, 0, 0, 0, 0, 0)
Assembly.ClearSelection2(True)
vResultingBodies = Assembly.FeatureManager.PreSplitBody()
splitFeat = Assembly.FeatureManager.PostSplitBody(vResultingBodies, False, bodyOrigins, "")
Else Else
splitBodyName = "HorizontalSplitBody"
End If
Dim gratingBodies = components(indexGrating).GetBodies2(0) Dim gratingBodies = components(indexGrating).GetBodies2(0)
Dim cutBodyIndex As Integer Dim cutBodyIndex As Integer
For k = 0 To gratingBodies.Length - 1 For l = 0 To gratingBodies.Length - 1
If gratingBodies(k).Name = "HorizontalSplitBody" Then If gratingBodies(l).Name = splitBodyName Then
cutBodyIndex = k cutBodyIndex = l
Exit For Exit For
End If End If
Next Next
Dim cutBody = gratingBodies(cutBodyIndex) Dim cutBody = gratingBodies(cutBodyIndex)
Dim recessBodies = components(indexRecess2).GetBodies2(0)
For l = 0 To recessBodies.Length - 1
If recessBodies(l).Name <> "Boss-Extrude1" Then
Dim recessBody = recessBodies(l)
Assembly.ClearSelection2(True) Assembly.ClearSelection2(True)
sldata.Mark = 1 sldata.Mark = 1
Dim bodyName As String = recessBody.Name & "@" & recessPartName & "-1@" & designName Dim bodyName As String = recessBodies(l).Name & "@" & recessPartName2 & "-1@" & designName
boolstatus = AssemblyExtension.SelectByID2(bodyName, "SOLIDBODY", 0, 0, 0, True, 1, Nothing, 0) boolstatus = AssemblyExtension.SelectByID2(bodyName, "SOLIDBODY", 0, 0, 0, True, 1, Nothing, 0)
sldata.Mark = 4 sldata.Mark = 4
@ -399,18 +372,113 @@ Public Class Model_3D_Fill
cutFace.Select4(True, sldata) cutFace.Select4(True, sldata)
Assembly.FeatureManager.InsertIndent(0.01, 0, False, True, True, False) Assembly.FeatureManager.InsertIndent(0.01, 0, False, True, True, False)
End If End If
Next
Next
Assembly.ClearSelection2(True) Assembly.ClearSelection2(True)
Next
Assembly.EditAssembly Assembly.EditAssembly
Next Next
Next 'Dim recessBodyIndex As Integer
'For k = 0 To recessBodies.Length - 1
' If recessBodies(k).Name = bodyToSplit Then 'Kommer ändras
' recessBodyIndex = k
' Exit For
' End If
'Next
'Dim recessBody = recessBodies(recessBodyIndex)
'Dim splitBodyName As String
'Dim numOfSplits As Integer
'If Math.Abs(tempList(0) - tempList(1)) = 1 Then
' splitBodyName = "VerticalSplitBody"
' numOfSplits = Grating_Fill.numOfHorizontal
'Else
' splitBodyName = "HorizontalSplitBody"
' numOfSplits = Grating_Fill.numOfVertical
'End If
'For k = 0 To numOfSplits - 1
' gratingPartName = partDT.Rows(Data.recessData.Rows(i)("GRATINGS")(j + k))("partName")
' For l = 0 To components.Length - 1
' If components(l).Name2 = gratingPartName & "-1" Then
' indexGrating = l
' Exit For
' End If
' Next
' Dim gratingBodies = components(indexGrating).GetBodies2(0)
' Dim cutBodyIndex As Integer
' For l = 0 To gratingBodies.Length - 1
' If gratingBodies(l).Name = splitBodyName Then
' cutBodyIndex = l
' Exit For
' End If
' Next
' Dim cutBody = gratingBodies(cutBodyIndex)
' Assembly.ClearSelection2(True)
' sldata.Mark = 1
' Dim bodyName As String = recessBody.Name & "@" & recessPartName & "-1@" & designName
' boolstatus = AssemblyExtension.SelectByID2(bodyName, "SOLIDBODY", 0, 0, 0, True, 1, Nothing, 0)
' sldata.Mark = 4
' Dim cutFace = cutBody.GetFirstFace
' cutFace.Select4(True, sldata)
' Assembly.FeatureManager.InsertIndent(0.01, 0, False, True, True, False)
' Next
''Plane split
'gratingPartName = partDT.Rows(Data.recessData.Rows(i)("GRATINGS")(j + k))("partName")
'Dim planeName As String = "VerticalSplitPlane@" & gratingPartName & "-1@" & designName
'boolstatus = AssemblyExtension.SelectByID2(planeName, "PLANE", 0, 0, 0, True, 0, Nothing, 0)
'Dim RefPlane As Object
'RefPlane = Assembly.FeatureManager.InsertRefPlane(4, 0, 0, 0, 0, 0)
'Assembly.ClearSelection2(True)
'planeName = "Top Plane@" & recessPartName & "-1@" & designName
'boolstatus = AssemblyExtension.SelectByID2(planeName, "PLANE", 0, 0, 0, True, 0, Nothing, 0)
'Dim swCompEnt = SelMgr.GetSelectedObject6(1, 0)
'Dim swComp = SelMgr.GetSelectedObjectsComponent3(1, 0)
'Dim swCompModel = swComp.GetModelDoc
'Dim swFeat As SldWorks.Feature
'swFeat = swCompModel.FirstFeature
'Dim planeFeat As SldWorks.Feature
'Do While Not swFeat Is Nothing
' planeFeat = swFeat
' swFeat = swFeat.GetNextFeature
'Loop
'Assembly.ClearSelection2(True)
'planeName = planeFeat.Name & "@" & recessPartName & "-1@" & designName
'boolstatus = AssemblyExtension.SelectByID2(planeName, "PLANE", 0, 0, 0, True, 0, Nothing, 0)
'Dim vResultingBodies As Object
'vResultingBodies = Assembly.FeatureManager.PreSplitBody()
'Dim bodyOrigins(1) As Object
'bodyOrigins(0) = Nothing
'bodyOrigins(1) = Nothing
'Dim splitFeat As SldWorks.Feature
'splitFeat = Assembly.FeatureManager.PostSplitBody(vResultingBodies, False, bodyOrigins, "")
'Assembly.ClearSelection2(True)
End Sub End Sub
Private Shared Sub Recess_Indent2() Private Shared Sub Recess_Indent2()