Plane Split
This commit is contained in:
parent
7bc80d2f23
commit
6a1a75fab2
Binary file not shown.
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
Public Class Individual
|
Public Class Individual
|
||||||
'Public Shared filepath As String = "C:\Users\Anton\Documents\Exjobb"
|
Public Shared filepath As String = "C:\Users\Anton\Documents\Exjobb"
|
||||||
Public Shared filepath As String = "C:\Users\xperd\Documents"
|
'Public Shared filepath As String = "C:\Users\xperd\Documents"
|
||||||
|
|
||||||
Sub Load_GUI()
|
Sub Load_GUI()
|
||||||
' Initialize GUI
|
' Initialize GUI
|
||||||
|
|
@ -245,6 +245,9 @@ Public Class Individual
|
||||||
' --- When export to SW button is pressed ---
|
' --- When export to SW button is pressed ---
|
||||||
Private Sub Button_Export_SW_Click(sender As Object, e As EventArgs) Handles Button_Export_SW.Click
|
Private Sub Button_Export_SW_Click(sender As Object, e As EventArgs) Handles Button_Export_SW.Click
|
||||||
If AppForm.fillMode Then
|
If AppForm.fillMode Then
|
||||||
|
Grating_Fill.Calculate_Grid()
|
||||||
|
Grating_Fill.Calculate_Recesses()
|
||||||
|
|
||||||
Model_3D_Fill.BuildGrid()
|
Model_3D_Fill.BuildGrid()
|
||||||
Else
|
Else
|
||||||
Model_3D.BuildGrating()
|
Model_3D.BuildGrating()
|
||||||
|
|
|
||||||
|
|
@ -144,12 +144,19 @@ Public Class Grating_Fill
|
||||||
Next
|
Next
|
||||||
|
|
||||||
Dim rowIndex As Integer
|
Dim rowIndex As Integer
|
||||||
For j = 0 To numOfVertical
|
For j = 0 To numOfVertical - 1
|
||||||
If pY >= j * maxSingleWidth AndAlso pY <= (j + 1) * maxSingleWidth Then
|
If widthRevNeeded AndAlso j = numOfVertical - 2 AndAlso pY >= j * maxSingleWidth AndAlso pY <= j * maxSingleWidth + revWidth Then
|
||||||
|
rowIndex = j
|
||||||
|
Exit For
|
||||||
|
ElseIf widthRevNeeded AndAlso j = numOfVertical - 1 Then
|
||||||
|
rowIndex = j
|
||||||
|
Exit For
|
||||||
|
ElseIf widthRevNeeded = False AndAlso pY >= j * maxSingleWidth AndAlso pY <= (j + 1) * maxSingleWidth Then
|
||||||
rowIndex = j
|
rowIndex = j
|
||||||
Exit For
|
Exit For
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
||||||
Dim gratingIndex As Integer = rowIndex * numOfHorizontal + colIndex
|
Dim gratingIndex As Integer = rowIndex * numOfHorizontal + colIndex
|
||||||
|
|
||||||
Dim tempList As New List(Of Integer)
|
Dim tempList As New List(Of Integer)
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,7 @@ Public Class Model_3D_Fill
|
||||||
|
|
||||||
Dim components = Assembly.GetComponents(True)
|
Dim components = Assembly.GetComponents(True)
|
||||||
|
|
||||||
|
'Combine
|
||||||
For i = 0 To gratingParts.Count - 1
|
For i = 0 To gratingParts.Count - 1
|
||||||
Assembly.ClearSelection2(True)
|
Assembly.ClearSelection2(True)
|
||||||
|
|
||||||
|
|
@ -222,23 +223,190 @@ 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
|
||||||
'sldata.Mark = 2
|
If gratingBodies(k).Name <> "HorizontalSplitBody" 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
|
||||||
Next
|
Next
|
||||||
Dim combinedFeature As SldWorks.Feature
|
Dim combinedFeature As SldWorks.Feature
|
||||||
Dim assemblyFeaMgr As SldWorks.IFeatureManager
|
Dim assemblyFeaMgr As SldWorks.IFeatureManager
|
||||||
|
|
||||||
assemblyFeaMgr = Assembly.FeatureManager
|
assemblyFeaMgr = Assembly.FeatureManager
|
||||||
combinedFeature = assemblyFeaMgr.InsertCombineFeature(15903, Nothing, Nothing)
|
combinedFeature = assemblyFeaMgr.InsertCombineFeature(15903, Nothing, Nothing)
|
||||||
'combinedFeature = Assembly.FeatureManager.InsertCombineFeature(15903, Nothing, Nothing)
|
|
||||||
'combinedFeature = assemblyFeaMgr.InsertCombineFeature(15903, Nothing, gratingBodies)
|
|
||||||
Assembly.EditAssembly
|
Assembly.EditAssembly
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
|
||||||
'Indent
|
'Indent
|
||||||
|
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 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 gratingBodyIndex As Integer
|
||||||
|
For k = 0 To gratingBodies.Length - 1
|
||||||
|
If gratingBodies(k).Name = "Combine1" Then
|
||||||
|
gratingBodyIndex = k
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
sldata.Mark = 1
|
||||||
|
|
||||||
|
Dim bodyName As String = gratingBodies(gratingBodyIndex).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)
|
||||||
|
|
||||||
|
|
||||||
|
Assembly.EditAssembly
|
||||||
|
Next
|
||||||
|
|
||||||
|
For j = 0 To tempList.Count - 2
|
||||||
|
Assembly.ClearSelection2(True)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
Assembly.EditPart
|
||||||
|
|
||||||
|
Dim gratingPartName As String = partDT.Rows(Data.recessData.Rows(i)("GRATINGS")(j))("partName")
|
||||||
|
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 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)
|
||||||
|
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
|
||||||
|
Dim gratingBodies = components(indexGrating).GetBodies2(0)
|
||||||
|
Dim cutBodyIndex As Integer
|
||||||
|
For k = 0 To gratingBodies.Length - 1
|
||||||
|
If gratingBodies(k).Name = "HorizontalSplitBody" Then
|
||||||
|
cutBodyIndex = k
|
||||||
|
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)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Assembly.ClearSelection2(True)
|
||||||
|
|
||||||
|
Assembly.EditAssembly
|
||||||
|
Next
|
||||||
|
|
||||||
|
Next
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -324,6 +492,9 @@ Public Class Model_3D_Fill
|
||||||
|
|
||||||
Assembly.EditAssembly
|
Assembly.EditAssembly
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Dim interfDectMgr As SldWorks.InterferenceDetectionMgr
|
Dim interfDectMgr As SldWorks.InterferenceDetectionMgr
|
||||||
'Dim interferences As Object
|
'Dim interferences As Object
|
||||||
'Dim interferenceBody As SldWorks.IBody2
|
'Dim interferenceBody As SldWorks.IBody2
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue