Interference of bodies - continued
This commit is contained in:
parent
0d0bcab73c
commit
9b1c9464a0
Binary file not shown.
|
|
@ -214,6 +214,9 @@ Public Class Model_3D_Fill
|
|||
Dim AssemblyExtension As SldWorks.ModelDocExtension
|
||||
|
||||
Dim Assembly = swApp.ActiveDoc
|
||||
Dim modelDoc As IModelDoc2
|
||||
modelDoc = Assembly
|
||||
|
||||
Dim SelMgr = Assembly.SelectionManager()
|
||||
AssemblyExtension = Assembly.Extension
|
||||
Dim sldata = SelMgr.CreateSelectData
|
||||
|
|
@ -225,39 +228,6 @@ Public Class Model_3D_Fill
|
|||
|
||||
Dim components = Assembly.GetComponents(True)
|
||||
|
||||
''Combine
|
||||
'For i = 0 To gratingParts.Count - 1
|
||||
' Assembly.ClearSelection2(True)
|
||||
|
||||
' Dim indexGrating As Integer
|
||||
' Dim gratingPartName As String = gratingParts(i)("partName")
|
||||
' For k = 0 To components.Length - 1
|
||||
' If components(k).Name2 = gratingPartName & "-1" Then
|
||||
' indexGrating = k
|
||||
' Exit For
|
||||
' End If
|
||||
' Next
|
||||
' boolstatus = AssemblyExtension.SelectByID2(gratingPartName & "-1@" & designName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
|
||||
' Assembly.EditPart
|
||||
|
||||
' Dim gratingBodies = components(indexGrating).GetBodies2(0)
|
||||
' Assembly.ClearSelection2(True)
|
||||
|
||||
' For k = 0 To gratingBodies.Length - 1
|
||||
' If gratingBodies(k).Name <> "HorizontalSplitBody" AndAlso gratingBodies(k).Name <> "VerticalSplitBody" Then
|
||||
' Dim bodyName As String = gratingBodies(k).Name & "@" & gratingPartName & "-1@" & designName
|
||||
' boolstatus = AssemblyExtension.SelectByID2(bodyName, "SOLIDBODY", 0, 0, 0, True, 2, Nothing, 0)
|
||||
' End If
|
||||
' Next
|
||||
' Dim combinedFeature As SldWorks.Feature
|
||||
' Dim assemblyFeaMgr As SldWorks.IFeatureManager
|
||||
|
||||
' assemblyFeaMgr = Assembly.FeatureManager
|
||||
' combinedFeature = assemblyFeaMgr.InsertCombineFeature(15903, Nothing, Nothing)
|
||||
|
||||
' Assembly.EditAssembly
|
||||
'Next
|
||||
|
||||
'Indent
|
||||
Dim recessParentName As String = partDT.Rows(Grating_Fill.numOfHorizontal * (Grating_Fill.numOfVertical - 1))("partName")
|
||||
Dim recessParts = partDT.Select("parentName = '" & recessParentName & "'")
|
||||
|
|
@ -296,8 +266,6 @@ Public Class Model_3D_Fill
|
|||
|
||||
Assembly.EditPart
|
||||
|
||||
Dim modelDoc As IModelDoc2
|
||||
modelDoc = Assembly
|
||||
boolstatus = AssemblyExtension.SelectByID2("HorizontalSplitBody@" & gratingPartName & "-1@" & designName, "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
|
||||
modelDoc.EditSuppress2()
|
||||
boolstatus = AssemblyExtension.SelectByID2("VerticalSplitBody@" & gratingPartName & "-1@" & designName, "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
|
||||
|
|
@ -311,19 +279,9 @@ Public Class Model_3D_Fill
|
|||
End If
|
||||
Next
|
||||
|
||||
'Dim gratingBodies = components(indexGrating).GetBodies2(0)
|
||||
Dim gratingComponent As SldWorks.Component2 = components(indexGrating)
|
||||
|
||||
'Dim gratingBodyIndex As Integer
|
||||
'For k = 0 To gratingBodies.Length - 1
|
||||
' If gratingBodies(k).Name <> "VerticalSplitBody" AndAlso gratingBodies(k).Name <> "HorizontalSplitBody" Then
|
||||
' gratingBodyIndex = k
|
||||
' Exit For
|
||||
' End If
|
||||
|
||||
'Next
|
||||
|
||||
Dim bodiesToCut = Check_Interference(gratingComponent, recessComponent)
|
||||
Dim bodiesToCut = Check_Interference(gratingComponent, recessComponent, gratingPartName & "-1")
|
||||
For k = 0 To bodiesToCut.Length - 1
|
||||
Assembly.ClearSelection2(True)
|
||||
|
||||
|
|
@ -338,7 +296,7 @@ Public Class Model_3D_Fill
|
|||
Assembly.ClearSelection2(True)
|
||||
Next
|
||||
|
||||
bodiesToCut = Check_Interference(gratingComponent, recessComponent)
|
||||
bodiesToCut = Check_Interference(gratingComponent, recessComponent, gratingPartName & "-1")
|
||||
For k = 0 To bodiesToCut.Length - 1
|
||||
boolstatus = AssemblyExtension.SelectByID2(bodiesToCut(k).Name & "@" & gratingPartName & "-1@" & designName, "SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)
|
||||
Dim myFeature As Object
|
||||
|
|
@ -362,45 +320,53 @@ Public Class Model_3D_Fill
|
|||
|
||||
Assembly.EditPart
|
||||
|
||||
boolstatus = AssemblyExtension.SelectByID2("Interference-Body@" & recessPartName & "-1@" & designName, "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
|
||||
modelDoc.EditSuppress2()
|
||||
boolstatus = AssemblyExtension.SelectByID2("Cut-Body@" & recessPartName & "-1@" & designName, "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
|
||||
modelDoc.EditSuppress2()
|
||||
|
||||
For j = 0 To Grating_Fill.numOfVertical * Grating_Fill.numOfHorizontal - 1
|
||||
For k = 1 To 2
|
||||
|
||||
Dim gratingPartName As String = partDT.Rows(j)("partName")
|
||||
Dim indexGrating As Integer
|
||||
For l = 0 To components.Length - 1
|
||||
If components(l).Name2 = gratingPartName & "-1" Then
|
||||
indexGrating = l
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim splitBodyName As String
|
||||
If k = 1 Then
|
||||
splitBodyName = "VerticalSplitBody"
|
||||
Else
|
||||
splitBodyName = "HorizontalSplitBody"
|
||||
Dim gratingPartName As String = partDT.Rows(j)("partName")
|
||||
Dim indexGrating As Integer
|
||||
For l = 0 To components.Length - 1
|
||||
If components(l).Name2 = gratingPartName & "-1" Then
|
||||
indexGrating = l
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Dim gratingComponent As SldWorks.Component2 = components(indexGrating)
|
||||
|
||||
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
|
||||
Dim bodiesToCut = Check_Interference(recessComponent, gratingComponent, recessPartName & "-1")
|
||||
|
||||
If bodiesToCut.Length > 0 Then
|
||||
For k = 1 To 2
|
||||
Dim splitBodyName As String
|
||||
If k = 1 Then
|
||||
splitBodyName = "VerticalSplitBody"
|
||||
Else
|
||||
splitBodyName = "HorizontalSplitBody"
|
||||
End If
|
||||
Next
|
||||
Dim cutBody = gratingBodies(cutBodyIndex)
|
||||
|
||||
recessBodies = components(indexRecess).GetBodies2(0)
|
||||
For l = 0 To recessBodies.Length - 1
|
||||
If recessBodies(l).Name <> "Cut-Body" Then
|
||||
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)
|
||||
|
||||
Dim recessBody = recessBodies(l)
|
||||
'recessBodies = components(indexRecess).GetBodies2(0)
|
||||
For l = 0 To bodiesToCut.Length - 1
|
||||
' If recessBodies(l).Name <> "Cut-Body" AndAlso recessBodies(l).Name <> "Interference-Body" Then
|
||||
|
||||
Dim recessBody = bodiesToCut(l)
|
||||
|
||||
Assembly.ClearSelection2(True)
|
||||
|
||||
sldata.Mark = 1
|
||||
Dim bodyName As String = recessBodies(l).Name & "@" & recessPartName & "-1@" & designName
|
||||
Dim bodyName As String = bodiesToCut(l).Name & "@" & recessPartName & "-1@" & designName
|
||||
boolstatus = AssemblyExtension.SelectByID2(bodyName, "SOLIDBODY", 0, 0, 0, True, 1, Nothing, 0)
|
||||
|
||||
sldata.Mark = 4
|
||||
|
|
@ -409,11 +375,17 @@ Public Class Model_3D_Fill
|
|||
|
||||
Assembly.FeatureManager.InsertIndent(0.01, 0, False, True, True, False)
|
||||
|
||||
End If
|
||||
'End If
|
||||
Next
|
||||
Next
|
||||
Next
|
||||
End If
|
||||
Assembly.ClearSelection2(True)
|
||||
Next
|
||||
|
||||
boolstatus = AssemblyExtension.SelectByID2("Interference-Body@" & recessPartName & "-1@" & designName, "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
|
||||
modelDoc.EditUnsuppress2()
|
||||
boolstatus = AssemblyExtension.SelectByID2("Cut-Body@" & recessPartName & "-1@" & designName, "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
|
||||
modelDoc.EditUnsuppress2()
|
||||
Assembly.EditAssembly
|
||||
End If
|
||||
Next
|
||||
|
|
@ -649,7 +621,7 @@ Public Class Model_3D_Fill
|
|||
End If
|
||||
End Function
|
||||
|
||||
Private Shared Function Check_Interference(comp1 As SldWorks.Component2, comp2 As SldWorks.Component2) ' Test Albins mocro för interference
|
||||
Private Shared Function Check_Interference(comp1 As SldWorks.Component2, comp2 As SldWorks.Component2, comp1Name As String)
|
||||
|
||||
Dim swApp As SldWorks.SldWorks
|
||||
Dim swModel As SldWorks.ModelDoc2
|
||||
|
|
@ -683,14 +655,13 @@ Public Class Model_3D_Fill
|
|||
|
||||
Next
|
||||
|
||||
Dim gratingName As String = CompNames(0)
|
||||
Dim bodiesToCutList As New List(Of Object)
|
||||
|
||||
If CompNames(0) = gratingName Then
|
||||
If CompNames(0) = comp1Name Then
|
||||
bodiesToCutList.Add(Bodies(0))
|
||||
End If
|
||||
For i = 1 To CompNames.Length - 1
|
||||
If CompNames(i) <> gratingName Then
|
||||
If CompNames(i) <> comp1Name Then
|
||||
Exit For
|
||||
ElseIf BodyNames(i) <> BodyNames(i - 1) Then
|
||||
bodiesToCutList.Add(Bodies(i))
|
||||
|
|
|
|||
Loading…
Reference in New Issue