226 lines
10 KiB
VB.net
226 lines
10 KiB
VB.net
Imports XCCLibrary
|
|
Imports SldWorks
|
|
Public Class Model_3D
|
|
Private Shared designName As String
|
|
Public Shared Sub BuildGrating()
|
|
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)
|
|
inst_ = ExternalClass.instantiate_parts(parentID, gratingParameters("TYPE"), "") ' Ange pressure_welded eller type A, Serrated?
|
|
ExternalClass.modify_parameter_value("DP_GRATING_WIDTH", inst_, gratingParameters("WIDTH"))
|
|
ExternalClass.modify_parameter_value("DP_GRATING_LENGTH", inst_, gratingParameters("LENGTH"))
|
|
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
|
|
|
|
'Instantiate recess rectangle
|
|
parentID = inst_
|
|
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" OrElse recessDR("RECESS TYPE") = "ANGLE" Then
|
|
If recessDR("RECESS TYPE") = "SQUARE" Then
|
|
inst_ = ExternalClass.instantiate_parts(parentID, "recess_rectangle", "")
|
|
Else
|
|
inst_ = ExternalClass.instantiate_parts(parentID, "recess_angle", "")
|
|
End If
|
|
Dim squareL As Integer = recessDR("LENGTH") + gratingParameters("LOADBAR_THICKNESS")
|
|
Dim squareW As Integer = recessDR("WIDTH") + gratingParameters("LOADBAR_THICKNESS")
|
|
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_, gratingParameters("WIDTH") - 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_, gratingParameters("WIDTH") - squareW)
|
|
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, gratingParameters("LENGTH") - 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_, gratingParameters("LENGTH") - 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") = "SIDE SQUARE" Then
|
|
'???
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
Private Shared Sub Recess_Indent()
|
|
Dim swApp As SldWorks.SldWorks
|
|
swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks)
|
|
|
|
Dim Assembly = swApp.ActiveDoc
|
|
|
|
Dim boolstatus As Boolean
|
|
|
|
|
|
'' Get all the parts in the model
|
|
'Dim dt As New DataTable
|
|
'dt = partModel.selectPart("*")
|
|
|
|
'Dim Design_table = designModel.selectDesign("*")
|
|
'Dim Design_name = Design_table.rows(0)("designName")
|
|
|
|
'' Get the quantity of each type
|
|
'Dim Nr_of_Rail = dt.Select("partType = 'RAIL'")
|
|
|
|
Dim partDT As New DataTable
|
|
partDT = partModel.selectPart("*")
|
|
|
|
Dim rectangleParts = partDT.Select("partType = 'recess_rectangle'")
|
|
|
|
'Gå in i durk part
|
|
Dim gratingPartName As String = "PRESSURE_WELDED_" & designName & "_092158497" & "-1@" & designName
|
|
|
|
boolstatus = Assembly.SelectByID2(gratingPartName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
|
|
|
|
Dim SelMgr = Assembly.SelectionManager()
|
|
Dim gratingPart = SelMgr.GetSelectedObject6(1, -1)
|
|
Assembly.EditPart
|
|
|
|
|
|
Dim recessPartName As String = "RECESS_RECTANGLE_" & designName & "_8457575" & "-1@" & designName
|
|
|
|
boolstatus = Assembly.SelectByID2(recessPartName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
|
|
|
|
Dim recessPart = SelMgr.GetSelectedObject6(1, -1)
|
|
|
|
boolstatus = gratingPart.Extension.SelectByID2("Solid Bodies", "BDYFOLDER", 0, 0, 0, False, 0, Nothing, 0)
|
|
Dim swFeat = SelMgr.GetSelectedObject6(1, -1)
|
|
|
|
Dim swBodyFolder = swFeat.GetSpecificFeature2
|
|
Dim Bodies = swBodyFolder.GetBodies()
|
|
|
|
Dim cutBodyName As String = "Boss-Extrude1"
|
|
|
|
Dim myFeature As Object
|
|
|
|
For i = 0 To (swBodyFolder.GetBodyCount() - 1)
|
|
Dim swBody = Bodies(i)
|
|
Dim bodyName As String = swBody.Name
|
|
boolstatus = gratingPart.Extension.SelectByID2(bodyName, "SOLIDBODY", 0, 0, 0, False, 1, Nothing, 0)
|
|
|
|
|
|
|
|
boolstatus = recessPart.Extension.SelectByID2(cutBodyName, "SOLIDBODY", 0, 0, 0, False, 1, Nothing, 0)
|
|
|
|
|
|
myFeature = gratingPart.FeatureManager.InsertIndent(0, 0, False, True, True, False) 'Första var 0.01
|
|
Next
|
|
|
|
'Loop
|
|
'Välj body
|
|
'Välj face (recess box)
|
|
'Indent
|
|
|
|
|
|
'Dim point2NameSW As String = "Point" & points(1) & "@Sketch1@" & CompName & "@" & myView.GetName2
|
|
|
|
'iDrawing.ClearSelection2(True)
|
|
|
|
'swExtensions.SelectByID2(point1NameSW, "EXTSKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
|
|
'swExtensions.SelectByID2(point2NameSW, "EXTSKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
|
|
|
|
|
|
|
|
|
|
'Dim Part As Object
|
|
'Dim boolstatus As Boolean
|
|
'Dim longstatus As Long, longwarnings As Long
|
|
|
|
|
|
|
|
'swApp = Application.SldWorks
|
|
|
|
'Part = swApp.ActiveDoc
|
|
'Set AssyDoc = swApp.ActiveDoc
|
|
'Set SelMgr = AssyDoc.SelectionManager()
|
|
|
|
'boolstatus = Part.Extension.SelectByID2("PRESSURE_WELDED_406_0922295_092158479-1@406_0922295", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0) 'Alltid pressure_welded eller type A
|
|
''boolstatus = Part.Extension.SelectByID2("PRESSURE_WELDED_" & designName _092158479 & "-1@" & designName", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
|
|
'Set Comp1 = SelMgr.GetSelectedObject6(1, -1)
|
|
'Part.EditPart
|
|
''Part.ClearSelection2 True
|
|
|
|
|
|
'For i = 0 To Part.getbodies().count 'Loopa igenom för så många bodies som finns i pressure_welded
|
|
' 'Select first body
|
|
|
|
' boolstatus = Part.Extension.SelectByID2("LPattern2[1]@PRESSURE_WELDED_406_0922295_092158479-1@406_0922295", "SOLIDBODY", 0.360768757122841, -0.410499999999985, -0.0160176749000129, False, 1, Nothing, 0) 'Loopa igenom all bodies
|
|
' 'boolstatus = Part.Extension.SelectByID2("first body", "SOLIDBODY", 0, 0, 0, False, 1, Nothing, 0)
|
|
|
|
' 'Select first face of recess box
|
|
' boolstatus = Part.Extension.SelectByRay(0.396886158235986, -0.412499999999909, -0.0485030769993955, 0.290449608622063, 0.476797615277708, -0.829640319003833, 0.00232083601043029, 2, True, 4, 0) ' Alltid recess boxen
|
|
' 'boolstatus = Part.Extension.SelectByID2("first face of recess box", "SOLIDBODY", 0, 0, 0, False, 1, Nothing, 0)
|
|
|
|
|
|
' Dim myFeature As Object
|
|
' Set myFeature = Part.FeatureManager.InsertIndent(0.01, 0, False, True, True, False)
|
|
|
|
'Next
|
|
End Sub
|
|
|
|
End Class
|