Angle recess indent implemented
This commit is contained in:
parent
c6e412384e
commit
ede62dc2cc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
|||
Imports XCCLibrary
|
||||
Public Class GUI
|
||||
'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\Anton\Documents\Exjobb"
|
||||
'Public Shared filepath As String = "C:\Users\xperd\Documents"
|
||||
|
||||
' --- Start method (main) for GUI ---
|
||||
Sub GUI_load() Handles MyBase.Load
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
Public Shared recessData As New DataTable
|
||||
|
||||
Public Shared pointCounter As Integer
|
||||
Public Shared pointsMeasurements As New Dictionary(Of String, Integer())
|
||||
|
||||
' --- Initialize Datatables, measurments and more ---
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@
|
|||
Dim dX As Decimal = GUI.Controls("X_TextBox").Text / 1000
|
||||
Dim dY As Decimal = GUI.Controls("Y_TextBox").Text / 1000
|
||||
|
||||
'Data.recessData.Rows.Add()
|
||||
Data.recessData.Rows.Add()
|
||||
|
||||
For i = 2 To Data.pointsMeasurements.Count - 1
|
||||
Dim mesName As String = Data.pointsMeasurements.Keys(i)
|
||||
|
|
@ -210,6 +210,13 @@
|
|||
pYGUI + dYGUI + 3, 1})
|
||||
Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text), pXGUI + dXGUI + 3,
|
||||
pYGUI + dYGUI / 2 - 4, 1})
|
||||
|
||||
' Recess Data
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("RECESS TYPE") = "ANGLE"
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("CORNER") = 1
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("WIDTH") = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("LENGTH") = CInt(GUI.Controls("X_TextBox").Text)
|
||||
|
||||
ElseIf pointQuadrant = 2 Then
|
||||
' Add the new points
|
||||
pointRow1("X") = pX - dX
|
||||
|
|
@ -243,6 +250,13 @@
|
|||
pYGUI + dYGUI / 2 - 4, 2})
|
||||
Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text), pXGUI - dXGUI / 2 - 8,
|
||||
pYGUI + dYGUI + 3, 2})
|
||||
|
||||
' Recess Data
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("RECESS TYPE") = "ANGLE"
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("CORNER") = 2
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("WIDTH") = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("LENGTH") = CInt(GUI.Controls("X_TextBox").Text)
|
||||
|
||||
ElseIf pointQuadrant = 3 Then
|
||||
' Add the new points
|
||||
pointRow1("X") = pX
|
||||
|
|
@ -275,6 +289,13 @@
|
|||
pYGUI - dYGUI - 12 - 3, 3})
|
||||
Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text), pXGUI - dXGUI - 18 - 3,
|
||||
pYGUI - dYGUI / 2 - 4, 3})
|
||||
|
||||
' Recess Data
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("RECESS TYPE") = "ANGLE"
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("CORNER") = 3
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("WIDTH") = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("LENGTH") = CInt(GUI.Controls("X_TextBox").Text)
|
||||
|
||||
Else
|
||||
' Add the new points
|
||||
pointRow1("X") = pX + dX
|
||||
|
|
@ -304,6 +325,13 @@
|
|||
pYGUI - dYGUI / 2 - 4, 4})
|
||||
Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text), pXGUI + dXGUI / 2 - 8,
|
||||
pYGUI - dYGUI - 12 - 3, 4})
|
||||
|
||||
' Recess Data
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("RECESS TYPE") = "ANGLE"
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("CORNER") = 4
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("WIDTH") = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("LENGTH") = CInt(GUI.Controls("X_TextBox").Text)
|
||||
|
||||
End If
|
||||
|
||||
Data.gratingPoints.Rows.InsertAt(pointRow1, index + 1)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
Imports XCCLibrary
|
||||
Imports SldWorks
|
||||
Imports System.Diagnostics
|
||||
|
||||
Public Class Model_3D
|
||||
Private Shared designName As String
|
||||
Public Shared Sub BuildGrating()
|
||||
|
|
@ -33,31 +35,24 @@ Public Class Model_3D
|
|||
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
|
||||
|
||||
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"))
|
||||
|
|
@ -72,7 +67,6 @@ Public Class Model_3D
|
|||
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"))
|
||||
|
|
@ -100,8 +94,41 @@ Public Class Model_3D
|
|||
ExternalClass.modify_parameter_value("DP_H_EDGEBAR_POS", inst_, squareW - gratingParameters("LOADBAR_THICKNESS"))
|
||||
End If
|
||||
|
||||
ElseIf recessDR("RECESS TYPE") = "SIDE SQUARE" Then
|
||||
'???
|
||||
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_, gratingParameters("WIDTH"))
|
||||
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_, gratingParameters("WIDTH"))
|
||||
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, gratingParameters("LENGTH"))
|
||||
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_, gratingParameters("LENGTH"))
|
||||
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
|
||||
End If
|
||||
|
||||
|
||||
|
|
@ -111,115 +138,81 @@ Public Class Model_3D
|
|||
Dim swApp As SldWorks.SldWorks
|
||||
swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks)
|
||||
|
||||
Dim Assembly = swApp.ActiveDoc
|
||||
|
||||
Dim boolstatus As Boolean
|
||||
Dim AssemblyExtension As SldWorks.ModelDocExtension
|
||||
|
||||
|
||||
'' 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 Assembly = swApp.ActiveDoc
|
||||
Dim SelMgr = Assembly.SelectionManager()
|
||||
AssemblyExtension = Assembly.Extension
|
||||
Dim sldata = SelMgr.CreateSelectData
|
||||
|
||||
Dim partDT As New DataTable
|
||||
partDT = partModel.selectPart("*")
|
||||
|
||||
Dim rectangleParts = partDT.Select("partType = 'recess_rectangle'")
|
||||
Assembly.ClearSelection2(True)
|
||||
|
||||
'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()
|
||||
' Grating part
|
||||
Dim gratingPartName As String = partDT.Rows(0)("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 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
|
||||
Dim indexGrating As Integer
|
||||
For i = 0 To components.Length - 1
|
||||
If components(i).Name2 = gratingPartName & "-1" Then
|
||||
indexGrating = i
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
'Loop
|
||||
'Välj body
|
||||
'Välj face (recess box)
|
||||
'Indent
|
||||
Dim gratingBodies = components(indexGrating).GetBodies2(0)
|
||||
|
||||
Dim recessParts = partDT.Select("parentName = '" & gratingPartName & "'")
|
||||
Dim recessPartName As String
|
||||
For i = 0 To recessParts.Count - 1
|
||||
Assembly.ClearSelection2(True)
|
||||
|
||||
'Dim point2NameSW As String = "Point" & points(1) & "@Sketch1@" & CompName & "@" & myView.GetName2
|
||||
' Recess part
|
||||
recessPartName = recessParts(i)("partName")
|
||||
boolstatus = AssemblyExtension.SelectByID2(recessPartName & "-1@" & designName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
|
||||
Dim recessPart = SelMgr.GetSelectedObject6(1, -1)
|
||||
|
||||
'iDrawing.ClearSelection2(True)
|
||||
Dim indexRecess As Integer
|
||||
For j = 0 To components.Length - 1
|
||||
If components(j).Name2 = recessPartName & "-1" Then
|
||||
indexRecess = j
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
'swExtensions.SelectByID2(point1NameSW, "EXTSKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
|
||||
'swExtensions.SelectByID2(point2NameSW, "EXTSKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
|
||||
Dim recessBodies = components(indexRecess).GetBodies2(0)
|
||||
|
||||
For j = 0 To gratingBodies.Length - 1
|
||||
sldata.Mark = 1
|
||||
|
||||
Dim bodyName As String = gratingBodies(j).Name & "@" & gratingPartName & "-1@" & designName
|
||||
boolstatus = AssemblyExtension.SelectByID2(bodyName, "SOLIDBODY", 0, 0, 0, True, 1, Nothing, 0)
|
||||
|
||||
sldata.Mark = 4
|
||||
|
||||
'Dim Part As Object
|
||||
'Dim boolstatus As Boolean
|
||||
'Dim longstatus As Long, longwarnings As Long
|
||||
Dim indexBody As Integer
|
||||
For k = 0 To recessBodies.Length - 1
|
||||
If recessBodies(k).Name = "Boss-Extrude1" Then
|
||||
indexBody = k
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim recessFace = recessBodies(indexBody).GetFirstFace
|
||||
recessFace.Select4(True, sldata)
|
||||
|
||||
|
||||
'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
|
||||
Assembly.FeatureManager.InsertIndent(0.01, 0, False, True, True, False)
|
||||
Assembly.ClearSelection2(True)
|
||||
Next
|
||||
Next
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
|
|
|||
Loading…
Reference in New Issue