Only indent interfering bodies fill function
This commit is contained in:
parent
4ace2261ca
commit
0d0bcab73c
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -114,6 +114,7 @@ Public Class Model_3D
|
|||
ExternalClass.modify_parameter_value("DP_WIDTH", inst_, squareW)
|
||||
ExternalClass.modify_parameter_value("DP_EDGEBAR_HEIGHT", inst_, gratingParameters("LOADBAR_HEIGHT"))
|
||||
ExternalClass.modify_parameter_value("DP_EDGEBAR_THICKNESS", inst_, gratingParameters("LOADBAR_THICKNESS"))
|
||||
ExternalClass.modify_parameter_value("DP_BOX_HEIGHT", inst_, gratingParameters("LOADBAR_HEIGHT"))
|
||||
|
||||
If recessDR("CORNER") = 1 Then
|
||||
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, gratingParameters("WIDTH") - squareW)
|
||||
|
|
@ -326,7 +327,7 @@ Public Class Model_3D
|
|||
|
||||
Dim indexBody As Integer
|
||||
For k = 0 To recessBodies.Length - 1
|
||||
If recessBodies(k).Name = "Boss-Extrude1" Then
|
||||
If recessBodies(k).Name = "Cut-Body" Then
|
||||
indexBody = k
|
||||
Exit For
|
||||
End If
|
||||
|
|
|
|||
|
|
@ -55,9 +55,8 @@ Public Class Model_3D_Fill
|
|||
designName = designTable.rows(0)("designName")
|
||||
groupClass.InstantiateGroup(designName, grNr, "START")
|
||||
|
||||
Check_Interference()
|
||||
Recess_Indent()
|
||||
Delete_Obsolete()
|
||||
Recess_Indent()
|
||||
|
||||
Save_Assembly()
|
||||
End Sub
|
||||
|
|
@ -86,6 +85,8 @@ Public Class Model_3D_Fill
|
|||
ExternalClass.modify_parameter_value("DP_WIDTH", inst_, squareW)
|
||||
ExternalClass.modify_parameter_value("DP_EDGEBAR_HEIGHT", inst_, gratingParameters("LOADBAR_HEIGHT"))
|
||||
ExternalClass.modify_parameter_value("DP_EDGEBAR_THICKNESS", inst_, gratingParameters("LOADBAR_THICKNESS"))
|
||||
ExternalClass.modify_parameter_value("DP_BOX_HEIGHT", inst_, gratingParameters("LOADBAR_HEIGHT"))
|
||||
|
||||
|
||||
If recessDR("CORNER") = 1 Then
|
||||
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, Data.gratingW - squareW)
|
||||
|
|
@ -224,166 +225,197 @@ Public Class Model_3D_Fill
|
|||
|
||||
Dim components = Assembly.GetComponents(True)
|
||||
|
||||
'Combine
|
||||
For i = 0 To gratingParts.Count - 1
|
||||
Assembly.ClearSelection2(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 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)
|
||||
' 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
|
||||
' 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)
|
||||
' assemblyFeaMgr = Assembly.FeatureManager
|
||||
' combinedFeature = assemblyFeaMgr.InsertCombineFeature(15903, Nothing, Nothing)
|
||||
|
||||
Assembly.EditAssembly
|
||||
Next
|
||||
' Assembly.EditAssembly
|
||||
'Next
|
||||
|
||||
'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 recessPartName As String = recessParts(i)("partName")
|
||||
If recessPartName.Split("_")(0) = "RECESS" Then
|
||||
|
||||
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 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
|
||||
|
||||
For j = 0 To Grating_Fill.numOfVertical * Grating_Fill.numOfHorizontal - 1
|
||||
Assembly.ClearSelection2(True)
|
||||
|
||||
Dim gratingPartName As String = partDT.Rows(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
|
||||
Dim indexRecess As Integer
|
||||
For k = 0 To components.Length - 1
|
||||
If components(k).Name2 = gratingPartName & "-1" Then
|
||||
indexGrating = k
|
||||
If components(k).Name2 = recessPartName & "-1" Then
|
||||
indexRecess = 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 <> "VerticalSplitBody" AndAlso gratingBodies(k).Name <> "HorizontalSplitBody" Then
|
||||
gratingBodyIndex = k
|
||||
Dim recessBodies = components(indexRecess).GetBodies2(0)
|
||||
Dim recessComponent As SldWorks.Component2 = components(indexRecess)
|
||||
|
||||
Dim indexBody As Integer
|
||||
For l = 0 To recessBodies.Length - 1
|
||||
If recessBodies(l).Name = "Cut-Body" Then
|
||||
indexBody = l
|
||||
Exit For
|
||||
End If
|
||||
|
||||
Next
|
||||
Assembly.ClearSelection2(True)
|
||||
|
||||
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)
|
||||
Dim recessFace = recessBodies(indexBody).GetFirstFace
|
||||
|
||||
sldata.Mark = 4
|
||||
recessFace.Select4(True, sldata)
|
||||
|
||||
Assembly.FeatureManager.InsertIndent(0.01, 0, False, True, True, False)
|
||||
|
||||
Assembly.ClearSelection2(True)
|
||||
Assembly.EditAssembly
|
||||
Next
|
||||
|
||||
Assembly.ClearSelection2(True)
|
||||
|
||||
boolstatus = AssemblyExtension.SelectByID2(recessPartName & "-1@" & designName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
|
||||
Dim recessPart2 = SelMgr.GetSelectedObject6(1, -1)
|
||||
|
||||
Assembly.EditPart
|
||||
|
||||
For j = 0 To Grating_Fill.numOfVertical * Grating_Fill.numOfHorizontal - 1
|
||||
For k = 1 To 2
|
||||
For j = 0 To Grating_Fill.numOfVertical * Grating_Fill.numOfHorizontal - 1
|
||||
Assembly.ClearSelection2(True)
|
||||
|
||||
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
|
||||
boolstatus = AssemblyExtension.SelectByID2(gratingPartName & "-1@" & designName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
|
||||
If boolstatus = True Then
|
||||
Dim gratingPart = SelMgr.GetSelectedObject6(1, -1)
|
||||
|
||||
Dim splitBodyName As String
|
||||
If k = 1 Then
|
||||
splitBodyName = "VerticalSplitBody"
|
||||
Else
|
||||
splitBodyName = "HorizontalSplitBody"
|
||||
End If
|
||||
Assembly.EditPart
|
||||
|
||||
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 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)
|
||||
modelDoc.EditSuppress2()
|
||||
|
||||
recessBodies = components(indexRecess).GetBodies2(0)
|
||||
For l = 0 To recessBodies.Length - 1
|
||||
If recessBodies(l).Name <> "Boss-Extrude1" Then
|
||||
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 recessBody = recessBodies(l)
|
||||
'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)
|
||||
For k = 0 To bodiesToCut.Length - 1
|
||||
Assembly.ClearSelection2(True)
|
||||
|
||||
sldata.Mark = 1
|
||||
Dim bodyName As String = recessBodies(l).Name & "@" & recessPartName & "-1@" & designName
|
||||
Dim bodyName As String = bodiesToCut(k).Name & "@" & gratingPartName & "-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)
|
||||
recessFace.Select4(True, sldata)
|
||||
|
||||
Assembly.FeatureManager.InsertIndent(0.01, 0, False, True, True, False)
|
||||
Assembly.ClearSelection2(True)
|
||||
Next
|
||||
|
||||
End If
|
||||
Next
|
||||
bodiesToCut = Check_Interference(gratingComponent, recessComponent)
|
||||
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
|
||||
Dim modelFeat As FeatureManager = modelDoc.FeatureManager
|
||||
myFeature = modelFeat.InsertDeleteBody2(False)
|
||||
Dim a = 1
|
||||
Next
|
||||
|
||||
boolstatus = AssemblyExtension.SelectByID2("HorizontalSplitBody@" & gratingPartName & "-1@" & designName, "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
|
||||
modelDoc.EditUnsuppress2()
|
||||
boolstatus = AssemblyExtension.SelectByID2("VerticalSplitBody@" & gratingPartName & "-1@" & designName, "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
|
||||
modelDoc.EditUnsuppress2()
|
||||
Assembly.EditAssembly
|
||||
End If
|
||||
Next
|
||||
|
||||
Assembly.ClearSelection2(True)
|
||||
Next
|
||||
Assembly.EditAssembly
|
||||
|
||||
boolstatus = AssemblyExtension.SelectByID2(recessPartName & "-1@" & designName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
|
||||
Dim recessPart2 = SelMgr.GetSelectedObject6(1, -1)
|
||||
|
||||
Assembly.EditPart
|
||||
|
||||
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"
|
||||
End If
|
||||
|
||||
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)
|
||||
|
||||
recessBodies = components(indexRecess).GetBodies2(0)
|
||||
For l = 0 To recessBodies.Length - 1
|
||||
If recessBodies(l).Name <> "Cut-Body" Then
|
||||
|
||||
Dim recessBody = recessBodies(l)
|
||||
|
||||
Assembly.ClearSelection2(True)
|
||||
|
||||
sldata.Mark = 1
|
||||
Dim bodyName As String = recessBodies(l).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
|
||||
Next
|
||||
Next
|
||||
Assembly.ClearSelection2(True)
|
||||
Next
|
||||
Assembly.EditAssembly
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
|
|
@ -617,12 +649,12 @@ Public Class Model_3D_Fill
|
|||
End If
|
||||
End Function
|
||||
|
||||
Private Shared Sub Check_Interference() ' Test Albins mocro för interference
|
||||
Private Shared Function Check_Interference(comp1 As SldWorks.Component2, comp2 As SldWorks.Component2) ' Test Albins mocro för interference
|
||||
|
||||
Dim swApp As SldWorks.SldWorks
|
||||
Dim swModel As SldWorks.ModelDoc2
|
||||
Dim swAssy As SldWorks.AssemblyDoc
|
||||
Dim CompArray(3) As SldWorks.Component2
|
||||
Dim CompArray(1) As SldWorks.Component2
|
||||
Dim vCompArray
|
||||
Dim vIntCompArray
|
||||
Dim vIntFaceArray
|
||||
|
|
@ -632,18 +664,12 @@ Public Class Model_3D_Fill
|
|||
swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks)
|
||||
swModel = swApp.ActiveDoc
|
||||
swAssy = swModel
|
||||
Dim components = swAssy.GetComponents(True)
|
||||
'CompArray = swAssy.GetComponents(True)
|
||||
'For i = 1 To components.length - 1
|
||||
CompArray(0) = components(0)
|
||||
CompArray(1) = components(1)
|
||||
CompArray(2) = components(2)
|
||||
CompArray(3) = components(3)
|
||||
'Next
|
||||
|
||||
CompArray(0) = comp1
|
||||
CompArray(1) = comp2
|
||||
|
||||
vCompArray = CompArray
|
||||
swAssy.ToolsCheckInterference2(4, (vCompArray), interfering, vIntCompArray, vIntFaceArray)
|
||||
|
||||
swAssy.ToolsCheckInterference2(2, (vCompArray), interfering, vIntCompArray, vIntFaceArray)
|
||||
|
||||
Dim Bodies(UBound(vIntFaceArray)) As Object
|
||||
Dim BodyNames(UBound(vIntFaceArray)) As String
|
||||
|
|
@ -656,5 +682,24 @@ Public Class Model_3D_Fill
|
|||
CompNames(i) = vIntCompArray(i).Name2
|
||||
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Dim gratingName As String = CompNames(0)
|
||||
Dim bodiesToCutList As New List(Of Object)
|
||||
|
||||
If CompNames(0) = gratingName Then
|
||||
bodiesToCutList.Add(Bodies(0))
|
||||
End If
|
||||
For i = 1 To CompNames.Length - 1
|
||||
If CompNames(i) <> gratingName Then
|
||||
Exit For
|
||||
ElseIf BodyNames(i) <> BodyNames(i - 1) Then
|
||||
bodiesToCutList.Add(Bodies(i))
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim bodiesToCut() As Object
|
||||
bodiesToCut = bodiesToCutList.ToArray()
|
||||
|
||||
Return bodiesToCut
|
||||
End Function
|
||||
End Class
|
||||
|
|
|
|||
Loading…
Reference in New Issue