Angle recess indent implemented

This commit is contained in:
Anton 2021-02-19 14:39:18 +01:00
parent c6e412384e
commit ede62dc2cc
8 changed files with 125 additions and 105 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +1,7 @@
Imports XCCLibrary Imports XCCLibrary
Public Class GUI Public Class GUI
'Public Shared filepath As String = "C:\Users\Anton\Documents\Exjobb" 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\xperd\Documents"
' --- Start method (main) for GUI --- ' --- Start method (main) for GUI ---
Sub GUI_load() Handles MyBase.Load Sub GUI_load() Handles MyBase.Load

View File

@ -15,7 +15,6 @@
Public Shared recessData As New DataTable Public Shared recessData As New DataTable
Public Shared pointCounter As Integer
Public Shared pointsMeasurements As New Dictionary(Of String, Integer()) Public Shared pointsMeasurements As New Dictionary(Of String, Integer())
' --- Initialize Datatables, measurments and more --- ' --- Initialize Datatables, measurments and more ---

View File

@ -108,7 +108,7 @@
Dim dX As Decimal = GUI.Controls("X_TextBox").Text / 1000 Dim dX As Decimal = GUI.Controls("X_TextBox").Text / 1000
Dim dY As Decimal = GUI.Controls("Y_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 For i = 2 To Data.pointsMeasurements.Count - 1
Dim mesName As String = Data.pointsMeasurements.Keys(i) Dim mesName As String = Data.pointsMeasurements.Keys(i)
@ -210,6 +210,13 @@
pYGUI + dYGUI + 3, 1}) pYGUI + dYGUI + 3, 1})
Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text), pXGUI + dXGUI + 3, Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text), pXGUI + dXGUI + 3,
pYGUI + dYGUI / 2 - 4, 1}) 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 ElseIf pointQuadrant = 2 Then
' Add the new points ' Add the new points
pointRow1("X") = pX - dX pointRow1("X") = pX - dX
@ -243,6 +250,13 @@
pYGUI + dYGUI / 2 - 4, 2}) pYGUI + dYGUI / 2 - 4, 2})
Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text), pXGUI - dXGUI / 2 - 8, Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text), pXGUI - dXGUI / 2 - 8,
pYGUI + dYGUI + 3, 2}) 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 ElseIf pointQuadrant = 3 Then
' Add the new points ' Add the new points
pointRow1("X") = pX pointRow1("X") = pX
@ -275,6 +289,13 @@
pYGUI - dYGUI - 12 - 3, 3}) pYGUI - dYGUI - 12 - 3, 3})
Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text), pXGUI - dXGUI - 18 - 3, Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text), pXGUI - dXGUI - 18 - 3,
pYGUI - dYGUI / 2 - 4, 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 Else
' Add the new points ' Add the new points
pointRow1("X") = pX + dX pointRow1("X") = pX + dX
@ -304,6 +325,13 @@
pYGUI - dYGUI / 2 - 4, 4}) pYGUI - dYGUI / 2 - 4, 4})
Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text), pXGUI + dXGUI / 2 - 8, Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text), pXGUI + dXGUI / 2 - 8,
pYGUI - dYGUI - 12 - 3, 4}) 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 End If
Data.gratingPoints.Rows.InsertAt(pointRow1, index + 1) Data.gratingPoints.Rows.InsertAt(pointRow1, index + 1)

View File

@ -1,5 +1,7 @@
Imports XCCLibrary Imports XCCLibrary
Imports SldWorks Imports SldWorks
Imports System.Diagnostics
Public Class Model_3D Public Class Model_3D
Private Shared designName As String Private Shared designName As String
Public Shared Sub BuildGrating() Public Shared Sub BuildGrating()
@ -33,31 +35,24 @@ Public Class Model_3D
Inst_Recesses(parentID, gratingParameters, recessDR) Inst_Recesses(parentID, gratingParameters, recessDR)
Next Next
importClass.copyGroupsByDataSet(ExternalClass.groupds_new) importClass.copyGroupsByDataSet(ExternalClass.groupds_new)
Dim grNr = groupClass.NewGroupID Dim grNr = groupClass.NewGroupID
Dim designTable = designModel.selectDesign("*") Dim designTable = designModel.selectDesign("*")
designName = designTable.rows(0)("designName") designName = designTable.rows(0)("designName")
groupClass.InstantiateGroup(designName, grNr, "START") groupClass.InstantiateGroup(designName, grNr, "START")
Recess_Indent() Recess_Indent()
End Sub End Sub
Private Shared Sub Inst_Recesses(parentID As Integer, gratingParameters As DataRow, recessDR As DataRow) Private Shared Sub Inst_Recesses(parentID As Integer, gratingParameters As DataRow, recessDR As DataRow)
Dim inst_ As Integer Dim inst_ As Integer
If recessDR("RECESS TYPE") = "SQUARE" OrElse recessDR("RECESS TYPE") = "ANGLE" Then
If recessDR("RECESS TYPE") = "SQUARE" 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 squareL As Integer = recessDR("LENGTH") + gratingParameters("LOADBAR_THICKNESS")
Dim squareW As Integer = recessDR("WIDTH") + 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_LENGTH", inst_, squareL + gratingParameters("LOADBAR_THICKNESS"))
ExternalClass.modify_parameter_value("DP_WIDTH", inst_, squareW) 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_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_V_EDGEBAR_BOTTOM", inst_, gratingParameters("LOADBAR_THICKNESS"))
ExternalClass.modify_parameter_value("DP_H_EDGEBAR_POS", inst_, 0) ExternalClass.modify_parameter_value("DP_H_EDGEBAR_POS", inst_, 0)
ElseIf recessDR("CORNER") = 2 Then ElseIf recessDR("CORNER") = 2 Then
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, gratingParameters("WIDTH") - squareW) 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")) 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")) ExternalClass.modify_parameter_value("DP_H_EDGEBAR_POS", inst_, squareW - gratingParameters("LOADBAR_THICKNESS"))
End If 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 End If
@ -111,115 +138,81 @@ Public Class Model_3D
Dim swApp As SldWorks.SldWorks Dim swApp As SldWorks.SldWorks
swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks) swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks)
Dim Assembly = swApp.ActiveDoc
Dim boolstatus As Boolean Dim boolstatus As Boolean
Dim AssemblyExtension As SldWorks.ModelDocExtension
Dim Assembly = swApp.ActiveDoc
'' Get all the parts in the model Dim SelMgr = Assembly.SelectionManager()
'Dim dt As New DataTable AssemblyExtension = Assembly.Extension
'dt = partModel.selectPart("*") Dim sldata = SelMgr.CreateSelectData
'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 Dim partDT As New DataTable
partDT = partModel.selectPart("*") partDT = partModel.selectPart("*")
Dim rectangleParts = partDT.Select("partType = 'recess_rectangle'") Assembly.ClearSelection2(True)
' in i durk part ' Grating part
Dim gratingPartName As String = "PRESSURE_WELDED_" & designName & "_092158497" & "-1@" & designName Dim gratingPartName As String = partDT.Rows(0)("partName")
boolstatus = AssemblyExtension.SelectByID2(gratingPartName & "-1@" & designName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Assembly.SelectByID2(gratingPartName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
Dim SelMgr = Assembly.SelectionManager()
Dim gratingPart = SelMgr.GetSelectedObject6(1, -1) Dim gratingPart = SelMgr.GetSelectedObject6(1, -1)
Assembly.EditPart Assembly.EditPart
Dim components = Assembly.GetComponents(True)
Dim recessPartName As String = "RECESS_RECTANGLE_" & designName & "_8457575" & "-1@" & designName Dim indexGrating As Integer
For i = 0 To components.Length - 1
boolstatus = Assembly.SelectByID2(recessPartName, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0) If components(i).Name2 = gratingPartName & "-1" Then
indexGrating = i
Dim recessPart = SelMgr.GetSelectedObject6(1, -1) Exit For
End If
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 Next
'Loop Dim gratingBodies = components(indexGrating).GetBodies2(0)
'Välj body
'Välj face (recess box)
'Indent
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) Dim recessBodies = components(indexRecess).GetBodies2(0)
'swExtensions.SelectByID2(point2NameSW, "EXTSKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 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 indexBody As Integer
'Dim boolstatus As Boolean For k = 0 To recessBodies.Length - 1
'Dim longstatus As Long, longwarnings As Long If recessBodies(k).Name = "Boss-Extrude1" Then
indexBody = k
Exit For
End If
Next
Dim recessFace = recessBodies(indexBody).GetFirstFace
recessFace.Select4(True, sldata)
Assembly.FeatureManager.InsertIndent(0.01, 0, False, True, True, False)
'swApp = Application.SldWorks Assembly.ClearSelection2(True)
Next
'Part = swApp.ActiveDoc Next
'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 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 Sub
End Class End Class