601 lines
27 KiB
VB.net
601 lines
27 KiB
VB.net
Imports XCCLibrary
|
|
|
|
Public Class Model_3D_Fill
|
|
Private Shared designName As String
|
|
Public Shared Sub BuildGrid()
|
|
Dim exportTable As DataTable
|
|
exportTable = User_Input.Create_ExportTable()
|
|
|
|
XCCBaseClass.newDesign()
|
|
ExternalClass.PopulateTamplateXMLGroup()
|
|
|
|
Dim inst_ As Integer
|
|
Dim parentID As Integer = 0
|
|
Dim gratingParameters As DataRow = exportTable.Rows(0)
|
|
|
|
For i = 0 To Grating_Fill.gratingDimensions.Rows.Count - 1
|
|
inst_ = ExternalClass.instantiate_parts(parentID, gratingParameters("TYPE"), "") ' Ange pressure_welded eller type A, Serrated?
|
|
ExternalClass.modify_parameter_value("DP_LOADBAR_THICKNESS", inst_, gratingParameters("LOADBAR_THICKNESS"))
|
|
ExternalClass.modify_parameter_value("DP_LOADBAR_HEIGHT", inst_, gratingParameters("LOADBAR_HEIGHT"))
|
|
ExternalClass.modify_parameter_value("DP_LOADBAR_SPACING", inst_, gratingParameters("LOADBAR_SPACING"))
|
|
ExternalClass.modify_parameter_value("DP_CROSSBAR_SPACING", inst_, gratingParameters("CROSSBAR_SPACING"))
|
|
|
|
If gratingParameters("TYPE") = "pressure_welded" Then
|
|
ExternalClass.modify_parameter_value("DP_CROSSBAR_DIAMETER", inst_, gratingParameters("CROSSBAR_DIAMETER"))
|
|
Else
|
|
ExternalClass.modify_parameter_value("DP_CROSSBAR_THICKNESS", inst_, gratingParameters("CROSSBAR_THICKNESS"))
|
|
ExternalClass.modify_parameter_value("DP_CROSSBAR_HEIGHT", inst_, gratingParameters("CROSSBAR_HEIGHT"))
|
|
End If
|
|
|
|
|
|
ExternalClass.modify_parameter_value("DP_GRATING_WIDTH", inst_, Grating_Fill.gratingDimensions.Rows(i)("WIDTH"))
|
|
ExternalClass.modify_parameter_value("DP_GRATING_LENGTH", inst_, Grating_Fill.gratingDimensions.Rows(i)("LENGTH"))
|
|
Dim offsetX As Integer = 0
|
|
For j = 1 To Grating_Fill.gratingDimensions.Rows(i)("COLUMN")
|
|
offsetX += Grating_Fill.gratingDimensions.Rows(i - j)("LENGTH")
|
|
|
|
Next
|
|
|
|
Dim offsetY As Integer = 0
|
|
For j = 1 To Grating_Fill.gratingDimensions.Rows(i)("ROW")
|
|
offsetY += Grating_Fill.gratingDimensions.Rows(i - Grating_Fill.numOfHorizontal * j)("WIDTH")
|
|
|
|
Next
|
|
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_X", inst_, (Grating_Fill.gratingDimensions.Rows(i)("LENGTH") / 2) + offsetX)
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_Y", inst_, (Grating_Fill.gratingDimensions.Rows(i)("WIDTH") / 2) + offsetY)
|
|
Next
|
|
|
|
parentID = Grating_Fill.numOfHorizontal * (Grating_Fill.numOfVertical - 1) + 1
|
|
For Each recessDR As DataRow In Data.recessData.Rows
|
|
Inst_Recesses(parentID, gratingParameters, recessDR)
|
|
Next
|
|
|
|
importClass.copyGroupsByDataSet(ExternalClass.groupds_new)
|
|
Dim grNr = groupClass.NewGroupID
|
|
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)
|
|
Dim inst_ As Integer
|
|
|
|
If recessDR("RECESS TYPE") = "SQUARE" Then
|
|
Dim squareL As Integer = recessDR("LENGTH") + gratingParameters("LOADBAR_THICKNESS")
|
|
Dim squareW As Integer = recessDR("WIDTH") + gratingParameters("LOADBAR_THICKNESS")
|
|
|
|
inst_ = ExternalClass.instantiate_parts(parentID, "recess_rectangle", "")
|
|
|
|
ExternalClass.modify_parameter_value("DP_LENGTH", inst_, squareL + gratingParameters("LOADBAR_THICKNESS"))
|
|
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"))
|
|
|
|
If recessDR("CORNER") = 1 Then
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, Data.gratingW - squareW)
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, 0)
|
|
|
|
'Position
|
|
ExternalClass.modify_parameter_value("DP_V_EDGEBAR_POS", inst_, squareL)
|
|
ExternalClass.modify_parameter_value("DP_V_EDGEBAR_BOTTOM", inst_, gratingParameters("LOADBAR_THICKNESS"))
|
|
ExternalClass.modify_parameter_value("DP_H_EDGEBAR_POS", inst_, 0)
|
|
|
|
ElseIf recessDR("CORNER") = 2 Then
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, Data.gratingW - squareW)
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, Data.gratingL - squareL - gratingParameters("LOADBAR_THICKNESS"))
|
|
|
|
'Position
|
|
ExternalClass.modify_parameter_value("DP_V_EDGEBAR_POS", inst_, 0)
|
|
ExternalClass.modify_parameter_value("DP_V_EDGEBAR_BOTTOM", inst_, gratingParameters("LOADBAR_THICKNESS"))
|
|
ExternalClass.modify_parameter_value("DP_H_EDGEBAR_POS", inst_, 0)
|
|
|
|
ElseIf recessDR("CORNER") = 3 Then
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, 0)
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, Data.gratingL - squareL - gratingParameters("LOADBAR_THICKNESS"))
|
|
|
|
'Position
|
|
ExternalClass.modify_parameter_value("DP_V_EDGEBAR_POS", inst_, 0)
|
|
ExternalClass.modify_parameter_value("DP_V_EDGEBAR_BOTTOM", inst_, 0)
|
|
ExternalClass.modify_parameter_value("DP_H_EDGEBAR_POS", inst_, squareW - gratingParameters("LOADBAR_THICKNESS"))
|
|
Else
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, 0)
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, 0)
|
|
|
|
'Position
|
|
ExternalClass.modify_parameter_value("DP_V_EDGEBAR_POS", inst_, squareL)
|
|
ExternalClass.modify_parameter_value("DP_V_EDGEBAR_BOTTOM", inst_, 0)
|
|
ExternalClass.modify_parameter_value("DP_H_EDGEBAR_POS", inst_, squareW - gratingParameters("LOADBAR_THICKNESS"))
|
|
End If
|
|
|
|
ElseIf recessDR("RECESS TYPE") = "ANGLE" Then
|
|
inst_ = ExternalClass.instantiate_parts(parentID, "recess_angle", "")
|
|
|
|
ExternalClass.modify_parameter_value("DP_EDGEBAR_HEIGHT", inst_, gratingParameters("LOADBAR_HEIGHT"))
|
|
ExternalClass.modify_parameter_value("DP_EDGEBAR_THICKNESS", inst_, gratingParameters("LOADBAR_THICKNESS"))
|
|
|
|
If recessDR("CORNER") = 1 Then
|
|
ExternalClass.modify_parameter_value("DP_LENGTH", inst_, recessDR("WIDTH"))
|
|
ExternalClass.modify_parameter_value("DP_WIDTH", inst_, recessDR("LENGTH"))
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, Data.gratingW)
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, 0)
|
|
ExternalClass.modify_parameter_value("DP_ROTATION", inst_, 90)
|
|
|
|
ElseIf recessDR("CORNER") = 2 Then
|
|
ExternalClass.modify_parameter_value("DP_LENGTH", inst_, recessDR("LENGTH"))
|
|
ExternalClass.modify_parameter_value("DP_WIDTH", inst_, recessDR("WIDTH"))
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, Data.gratingW)
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, Data.gratingL)
|
|
ExternalClass.modify_parameter_value("DP_ROTATION", inst_, 180)
|
|
|
|
ElseIf recessDR("CORNER") = 3 Then
|
|
ExternalClass.modify_parameter_value("DP_LENGTH", inst_, recessDR("WIDTH"))
|
|
ExternalClass.modify_parameter_value("DP_WIDTH", inst_, recessDR("LENGTH"))
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, 0)
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, Data.gratingL)
|
|
ExternalClass.modify_parameter_value("DP_ROTATION", inst_, 270)
|
|
|
|
Else
|
|
ExternalClass.modify_parameter_value("DP_LENGTH", inst_, recessDR("LENGTH"))
|
|
ExternalClass.modify_parameter_value("DP_WIDTH", inst_, recessDR("WIDTH"))
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, 0)
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, 0)
|
|
ExternalClass.modify_parameter_value("DP_ROTATION", inst_, 0)
|
|
|
|
End If
|
|
|
|
ElseIf recessDR("RECESS TYPE") = "SIDE SQUARE" Then
|
|
inst_ = ExternalClass.instantiate_parts(parentID, "recess_side_square", "")
|
|
|
|
ExternalClass.modify_parameter_value("DP_EDGEBAR_HEIGHT", inst_, gratingParameters("LOADBAR_HEIGHT"))
|
|
ExternalClass.modify_parameter_value("DP_EDGEBAR_THICKNESS", inst_, gratingParameters("LOADBAR_THICKNESS"))
|
|
|
|
If recessDR("SIDE") = 1 Then
|
|
ExternalClass.modify_parameter_value("DP_LENGTH", inst_, recessDR("WIDTH"))
|
|
ExternalClass.modify_parameter_value("DP_WIDTH", inst_, recessDR("LENGTH"))
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, Data.gratingW)
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, recessDR("OFFSET"))
|
|
ExternalClass.modify_parameter_value("DP_ROTATION", inst_, 90)
|
|
|
|
ElseIf recessDR("SIDE") = 2 Then
|
|
ExternalClass.modify_parameter_value("DP_LENGTH", inst_, recessDR("LENGTH"))
|
|
ExternalClass.modify_parameter_value("DP_WIDTH", inst_, recessDR("WIDTH"))
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, Data.gratingW - recessDR("OFFSET"))
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, Data.gratingL)
|
|
ExternalClass.modify_parameter_value("DP_ROTATION", inst_, 180)
|
|
|
|
ElseIf recessDR("SIDE") = 3 Then
|
|
ExternalClass.modify_parameter_value("DP_LENGTH", inst_, recessDR("WIDTH"))
|
|
ExternalClass.modify_parameter_value("DP_WIDTH", inst_, recessDR("LENGTH"))
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, 0)
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, Data.gratingL - recessDR("OFFSET"))
|
|
ExternalClass.modify_parameter_value("DP_ROTATION", inst_, 270)
|
|
|
|
Else
|
|
ExternalClass.modify_parameter_value("DP_LENGTH", inst_, recessDR("LENGTH"))
|
|
ExternalClass.modify_parameter_value("DP_WIDTH", inst_, recessDR("WIDTH"))
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, recessDR("OFFSET"))
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, 0)
|
|
ExternalClass.modify_parameter_value("DP_ROTATION", inst_, 0)
|
|
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Shared Sub Recess_Indent()
|
|
'Combine all bodies
|
|
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 gratingParts = partDT.Select("parentName = 'START'")
|
|
|
|
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 & "'")
|
|
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
|
|
|
|
|
|
|
|
Assembly.ClearSelection2(True)
|
|
|
|
Dim recessPartName2 As String = recessParts(i)("partName")
|
|
boolstatus = AssemblyExtension.SelectByID2(recessPartName2 & "-1@" & designName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
|
|
Dim recessPart2 = SelMgr.GetSelectedObject6(1, -1)
|
|
|
|
Assembly.EditPart
|
|
|
|
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
|
|
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)
|
|
|
|
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)
|
|
|
|
sldata.Mark = 1
|
|
Dim bodyName As String = recessBodies(l).Name & "@" & recessPartName2 & "-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
|
|
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
|
|
|
|
Private Shared Sub Recess_Indent2()
|
|
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
|
|
|
|
|
|
|
|
Dim interfDectMgr As SldWorks.InterferenceDetectionMgr
|
|
'Dim interferences As Object
|
|
'Dim interferenceBody As SldWorks.IBody2
|
|
Assembly.ToolsCheckInterference
|
|
|
|
interfDectMgr = Assembly.InterferenceDetectionManager
|
|
|
|
interfDectMgr.TreatCoincidenceAsInterference = False
|
|
interfDectMgr.TreatSubAssembliesAsComponents = False
|
|
interfDectMgr.IncludeMultibodyPartInterferences = True
|
|
interfDectMgr.MakeInterferingPartsTransparent = True
|
|
interfDectMgr.CreateFastenersFolder = False
|
|
interfDectMgr.IgnoreHiddenBodies = False
|
|
interfDectMgr.ShowIgnoredInterferences = False
|
|
interfDectMgr.UseTransform = False
|
|
|
|
Dim interferences = interfDectMgr.GetInterferences()
|
|
'Dim tempinter As SldWorks.Interference
|
|
Dim tempinter = interferences(1)
|
|
Dim interferenceBody = tempinter.GetInterferenceBody()
|
|
Dim tempdata As SldWorks.SelectData
|
|
Dim tempbool As Boolean
|
|
tempbool = interferenceBody.Select2(True, tempdata)
|
|
|
|
Dim intBodyName As String = interferenceBody.Name
|
|
|
|
'interferenceBody.DisableDisplay = True
|
|
Dim a = 1
|
|
Next
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
End Class
|