diff --git a/CatiaNetTest/AndOrDataExtraction.vb b/CatiaNetTest/AndOrDataExtraction.vb index 580dc931136d4ceba7a642a4e548be127369f6b4..9d52bc47e4b8e5dcd0170cc7947ab2e051839980 100644 --- a/CatiaNetTest/AndOrDataExtraction.vb +++ b/CatiaNetTest/AndOrDataExtraction.vb @@ -18,6 +18,7 @@ Public Class AndOrDataExtraction Public intStep As Integer Public dCollSens As Double Public xlsPath As String + Public xlsFileName As String Public cAllProducts As New ArrayList Public cRelevantProducts As New ArrayList Public intParts As Integer @@ -44,8 +45,9 @@ Public Class AndOrDataExtraction bGenerateANDOR = False bAutomaticStep = True intStep = 13 - dCollSens = 2 - xlsPath = "D:\mikep\Files\RWTH\Master Produktionstechnik\Masterarbeit\Experimente\Protocols" + dCollSens = 1 + xlsPath = "D:\mikep\Files\RWTH\Master Produktionstechnik\Masterarbeit\Experimente\Protocols\" + xlsFileName = "UglyStikRC" CATIA = GetObject(, "CATIA.Application") If CATIA Is Nothing Then CATIA = CreateObject("CATIA.Application") @@ -470,6 +472,7 @@ Public Class AndOrDataExtraction End If Next c End If + cClashes.Remove(cClashes.Count) Loop Next d Next int_i @@ -503,7 +506,6 @@ Public Class AndOrDataExtraction Next int_i 'Save and close excel workbook - Dim xlsFileName As String = CATIA.ActiveDocument.Name oExcel.ActiveWorkbook.SaveAs(Filename:=xlsPath & xlsFileName & "_Moving wedge.xlsx") oExcel.ActiveWorkbook.Close(SaveChanges:=True) 'close the excel application @@ -597,7 +599,6 @@ Public Class AndOrDataExtraction MsgBox("Liaison graph extraction took " & CStr(SecondsElapsed) & " seconds") 'Save and close excel workbook - Dim xlsFileName As String = CATIA.ActiveDocument.Name objExcel.ActiveWorkbook.SaveAs(Filename:=xlsPath & xlsFileName & "_Liaisons.xlsx") objExcel.ActiveWorkbook.Close(SaveChanges:=True) 'close the excel application diff --git a/CatiaNetTest/AssemblyTiers2.vb b/CatiaNetTest/AssemblyTiers2.vb index 2fd78a982435e2d8b9990483df317eeb745ede18..60db50de2baab87b1ce628dc1e3b912c4cd9f3ba 100644 --- a/CatiaNetTest/AssemblyTiers2.vb +++ b/CatiaNetTest/AssemblyTiers2.vb @@ -9,15 +9,29 @@ Imports PARTITF Imports Microsoft.Office.Interop.Excel Public Class AssemblyTiers2 + Inherits Form + + Friend WithEvents OKButton As System.Windows.Forms.Button = New System.Windows.Forms.Button() + Friend WithEvents BBCodeComboBox As System.Windows.Forms.ComboBox = New ComboBox() + Friend WithEvents BBPCCheckBox As System.Windows.Forms.CheckBox = New System.Windows.Forms.CheckBox() + Friend WithEvents CCCheckBox As System.Windows.Forms.CheckBox = New System.Windows.Forms.CheckBox() + Friend WithEvents AutoStepCheckBox As System.Windows.Forms.CheckBox = New System.Windows.Forms.CheckBox() + Friend WithEvents StepTextBox As System.Windows.Forms.TextBox = New System.Windows.Forms.TextBox() + Friend WithEvents CollSensTextBox As System.Windows.Forms.TextBox = New System.Windows.Forms.TextBox() + Friend WithEvents ExtractDirCheckBox As System.Windows.Forms.CheckBox = New System.Windows.Forms.CheckBox() + Friend WithEvents AxisComboBox As System.Windows.Forms.ComboBox = New System.Windows.Forms.ComboBox() + Friend WithEvents XLSTextBox As System.Windows.Forms.TextBox = New System.Windows.Forms.TextBox() Public bConnectivityCheck As Boolean Public bBoundingBoxProjectionCheck As Boolean Public bAutomaticStep As Boolean Public bChooseExtractionDirection As Boolean + Public intJ As Integer Public iBoundingBoxCode As Integer Public intStep As Integer Public dCollSens As Double Public xlsPath As String + Public xlsFileName As String Public intParts As Integer Public intNumFaces As Integer Public primaryFasteners As New ArrayList @@ -37,19 +51,19 @@ Public Class AssemblyTiers2 Sub CatMain() - 'Test parameters - iBoundingBoxCode = 1 - bBoundingBoxProjectionCheck = True - bConnectivityCheck = True - bAutomaticStep = True - intStep = 13 - dCollSens = 2 - bChooseExtractionDirection = False - 'number of analysed disassembly directions - Dim intJ As Integer - '6 - only global axes, 12 - including local axes - intJ = 6 - xlsPath = "D:\mikep\Files\RWTH\Master Produktionstechnik\Masterarbeit\Experimente\Protocols" + ''Test parameters + 'iBoundingBoxCode = 1 + 'bBoundingBoxProjectionCheck = True + 'bConnectivityCheck = False + 'bAutomaticStep = False + 'intStep = 5 + 'dCollSens = 2 + 'bChooseExtractionDirection = False + ''number of analysed disassembly directions + ''6 - only global axes, 12 - including local axes + 'intJ = 6 + xlsPath = "D:\mikep\Files\RWTH\Master Produktionstechnik\Masterarbeit\Experimente\Protocols\" + 'xlsFileName = "Centrifugal pump 5mm step" CATIA = GetObject(, "CATIA.Application") If CATIA Is Nothing Then CATIA = CreateObject("CATIA.Application") @@ -296,6 +310,19 @@ Public Class AssemblyTiers2 product1 = cRelevantProducts.Item(int_i) Debug.Print("Processing " & product1.Name & " [tier=" & intTier & ", i_cycle=" & int_i_cycle & ", I=" & intI & "]") + 'Remember initial position P_i (initPos) + Dim initPos(11) + Dim oPosition1 As Object + oPosition1 = product1.Position + oPosition1.GetComponents(initPos) + If bInitPosRecorded(int_i) = False Then + Dim ip As Integer + For ip = 0 To 11 + aInitPos(int_i, ip) = initPos(ip) + Next ip + bInitPosRecorded(int_i) = True + End If + 'Skip not moveable products If Not bMoveable(int_i) Then 'the part is a base component or deactivated @@ -328,19 +355,6 @@ Public Class AssemblyTiers2 End If End If - 'Remember initial position P_i (initPos) - Dim initPos(11) - Dim oPosition1 As Object - oPosition1 = product1.Position - oPosition1.GetComponents(initPos) - If bInitPosRecorded(int_i) = False Then - Dim ip As Integer - For ip = 0 To 11 - aInitPos(int_i, ip) = initPos(ip) - Next ip - bInitPosRecorded(int_i) = True - End If - 'Group that includes our product (needed for collision detection between two selections or groups) Dim group1 As Group group1 = cGroups.Add @@ -473,7 +487,7 @@ exit2: int_i = int_i + 1 int_i_cycle = int_i_cycle + 1 int_j = 0 - int_j_temp = 0 + int_j_temp = -1 'if active products remain in this cycle... If int_i_cycle <= intI - cBaseProducts.Count Then @@ -510,17 +524,7 @@ exit2: 'cVirtual.Add cRelevantProducts.Item(p) 'fix position bMoveable(p) = False - 'Deactivate last disassembly tier directly - If intI = cBaseProducts.Count - 1 Then - Dim selektion As Selection - selektion = CATIA.ActiveDocument.Selection - selektion.Clear() - selektion.Add(cRelevantProducts.Item(p)) - CATIA.StartCommand("Activate / Deactivate Component") - selektion.Clear() - cDeactivated.Add(cRelevantProducts.Item(p)) - bDeactivated(p) = True - End If + End If 'product from higher tier If productHasValidDisassDir(p, disassDir) And aTiers(p) = intTier - 1 Then @@ -537,9 +541,35 @@ exit2: End If Next p + 'Deactivate last disassembly tier directly + For p = 0 To cRelevantProducts.Count - 1 + If intI = cBaseProducts.Count - 1 And aTiers(p) = intTier Then + Dim selektion As Selection + selektion = CATIA.ActiveDocument.Selection + selektion.Clear() + selektion.Add(cRelevantProducts.Item(p)) + CATIA.StartCommand("Activate / Deactivate Component") + selektion.Clear() + cDeactivated.Add(cRelevantProducts.Item(p)) + bDeactivated(p) = True + End If + Next p + 'Notify the user if no parts could be disassembled in this tier If intI = intItemp Then Debug.Print("WARNING! No parts could be removed during this cycle." & vbNewLine & "This is usually due to inaccuracies in modelling (e.g. collisions in initial assembly).") + For p = 0 To cRelevantProducts.Count - 1 + If aTiers(p) = 0 And Not productIsInCollection(cRelevantProducts.Item(p), cBaseProducts) Then + Dim selektion As Selection + selektion = CATIA.ActiveDocument.Selection + selektion.Clear() + selektion.Add(cRelevantProducts.Item(p)) + CATIA.StartCommand("Activate / Deactivate Component") + selektion.Clear() + cDeactivated.Add(cRelevantProducts.Item(p)) + bDeactivated(p) = True + End If + Next p GoTo exitCD End If @@ -698,6 +728,7 @@ exitCD: Dim oClash1 As Clash oClash1 = cClashes.Add oClash1.ComputationType = CatClashComputationType.catClashComputationTypeBetweenAll + oClash1.InterferenceType = CatClashInterferenceType.catClashInterferenceTypeContact oClash1.Compute() Dim cInitConflicts As Conflicts cInitConflicts = oClash1.Conflicts @@ -753,8 +784,11 @@ exitCD: Next int_i 'Save and close excel workbook - Dim xlsFileName As String = CATIA.ActiveDocument.Name - objExcel.ActiveWorkbook.SaveAs(Filename:=xlsPath & xlsFileName & "_AssemblyTiers.xlsx") + If bConnectivityCheck Then + objExcel.ActiveWorkbook.SaveAs(Filename:=xlsPath & xlsFileName & "_AssemblyTiers_CC.xlsx") + Else + objExcel.ActiveWorkbook.SaveAs(Filename:=xlsPath & xlsFileName & "_AssemblyTiers.xlsx") + End If objExcel.ActiveWorkbook.Close(SaveChanges:=True) 'close the excel application objExcel.Quit() @@ -1400,7 +1434,7 @@ exitCD: Next n Next m - part1.Update + part1.Update() Exit For @@ -1699,7 +1733,7 @@ exitCD: oClash.SecondGroup = group2 oClash.InterferenceType = SPATypeLib.CatClashInterferenceType.catClashInterferenceTypeClearance 'oClash.Clearance = dCollSens - oClash.Compute + oClash.Compute() Dim cConflicts As Conflicts cConflicts = oClash.Conflicts If cConflicts.Count > 0 Then @@ -1897,7 +1931,6 @@ Finish: objSheet1.Cells(int_i + 2, 2).Value = dPartBBVolume Next int_i 'Save and close excel workbook - Dim xlsFileName As String = CATIA.ActiveDocument.Name objExcel.ActiveWorkbook.SaveAs(Filename:=xlsPath & xlsFileName & "_BB Volumes.xlsx") objExcel.ActiveWorkbook.Close(SaveChanges:=True) 'close the excel application @@ -1920,4 +1953,131 @@ Finish: End Try End Sub + Sub ShowForm() + 'Create a new form to input algorithm specifications first + 'Dim Form2 As Form = New Form() + Me.Text = "Algorithm specifications" + Me.Size = New System.Drawing.Size(350, 400) + 'Create elements for parameter inputs + 'Code variant for BB calculation + 'Dim BBCodeComboBox As ComboBox = New ComboBox() + BBCodeComboBox.Items.Add(1) + BBCodeComboBox.Items.Add(2) + BBCodeComboBox.Location = New System.Drawing.Point(200, 20) + BBCodeComboBox.Size = New System.Drawing.Size(50, 20) + BBCodeComboBox.DropDownStyle = ComboBoxStyle.DropDownList + Dim Label1 As System.Windows.Forms.Label = New System.Windows.Forms.Label() + Label1.Text = "Bounding Box code type" + Label1.Location = New System.Drawing.Point(20, 20) + Label1.Size = New System.Drawing.Size(150, 20) + 'Projection check + 'Dim BBPCCheckBox As System.Windows.Forms.CheckBox = New System.Windows.Forms.CheckBox() + BBPCCheckBox.Location = New System.Drawing.Point(200, 50) + Dim Label2 As System.Windows.Forms.Label = New System.Windows.Forms.Label() + Label2.Text = "BB projection check" + Label2.Location = New System.Drawing.Point(20, 50) + Label2.Size = New System.Drawing.Size(150, 20) + 'Connectivity check + 'Dim CCCheckBox As System.Windows.Forms.CheckBox = New System.Windows.Forms.CheckBox() + CCCheckBox.Location = New System.Drawing.Point(200, 80) + Dim Label3 As System.Windows.Forms.Label = New System.Windows.Forms.Label() + Label3.Text = "Connectivity check" + Label3.Location = New System.Drawing.Point(20, 80) + Label3.Size = New System.Drawing.Size(150, 20) + 'Automatic step + 'Dim AutoStepCheckBox As System.Windows.Forms.CheckBox = New System.Windows.Forms.CheckBox() + AutoStepCheckBox.Location = New System.Drawing.Point(200, 110) + Dim Label4 As System.Windows.Forms.Label = New System.Windows.Forms.Label() + Label4.Text = "Automatic step" + Label4.Location = New System.Drawing.Point(20, 110) + Label4.Size = New System.Drawing.Size(150, 20) + 'Step + 'Dim StepTextBox As System.Windows.Forms.TextBox = New System.Windows.Forms.TextBox() + StepTextBox.Text = 5 + StepTextBox.Location = New System.Drawing.Point(200, 140) + StepTextBox.Size = New System.Drawing.Size(50, 20) + Dim Label5 As System.Windows.Forms.Label = New System.Windows.Forms.Label() + Label5.Text = "Step [mm]" + Label5.Location = New System.Drawing.Point(20, 140) + Label5.Size = New System.Drawing.Size(150, 20) + 'Collision sensitivity + 'Dim CollSensTextBox As System.Windows.Forms.TextBox = New System.Windows.Forms.TextBox() + CollSensTextBox.Text = 2 + CollSensTextBox.Location = New System.Drawing.Point(200, 170) + CollSensTextBox.Size = New System.Drawing.Size(50, 20) + Dim Label6 As System.Windows.Forms.Label = New System.Windows.Forms.Label() + Label6.Text = "Collision sensitivity [mm]" + Label6.Location = New System.Drawing.Point(20, 170) + Label6.Size = New System.Drawing.Size(150, 20) + 'Choice of extraction direction + 'Dim ExtractDirCheckBox As System.Windows.Forms.CheckBox = New System.Windows.Forms.CheckBox() + ExtractDirCheckBox.Location = New System.Drawing.Point(200, 200) + Dim Label7 As System.Windows.Forms.Label = New System.Windows.Forms.Label() + Label7.Text = "Choice of disassembly axis" + Label7.Location = New System.Drawing.Point(20, 200) + Label7.Size = New System.Drawing.Size(150, 20) + 'Number of disassembly axis + 'Dim AxisComboBox As ComboBox = New ComboBox() + AxisComboBox.Items.Add(6) + AxisComboBox.Items.Add(12) + AxisComboBox.Location = New System.Drawing.Point(200, 230) + AxisComboBox.Size = New System.Drawing.Size(50, 20) + AxisComboBox.DropDownStyle = ComboBoxStyle.DropDownList + Dim Label8 As System.Windows.Forms.Label = New System.Windows.Forms.Label() + Label8.Text = "Number of disassembly axis" + Label8.Location = New System.Drawing.Point(20, 230) + Label8.Size = New System.Drawing.Size(150, 20) + 'Desired name of the output Excel file + 'Dim XLSTextBox As System.Windows.Forms.TextBox = New System.Windows.Forms.TextBox() + XLSTextBox.Text = "Product" + XLSTextBox.Location = New System.Drawing.Point(200, 260) + Dim Label9 As System.Windows.Forms.Label = New System.Windows.Forms.Label() + Label9.Text = "Excel file name" + Label9.Location = New System.Drawing.Point(20, 260) + Label9.Size = New System.Drawing.Size(150, 20) + 'OK button + 'Dim OKButton As System.Windows.Forms.Button = New System.Windows.Forms.Button() + OKButton.Text = "Accept parameters" + OKButton.Location = New System.Drawing.Point(100, 310) + OKButton.Size = New System.Drawing.Size(150, 40) + + 'Add control elements to the form + Me.Controls.Add(Label1) + Me.Controls.Add(Label2) + Me.Controls.Add(Label3) + Me.Controls.Add(Label4) + Me.Controls.Add(Label5) + Me.Controls.Add(Label6) + Me.Controls.Add(Label7) + Me.Controls.Add(Label8) + Me.Controls.Add(Label9) + Me.Controls.Add(BBCodeComboBox) + Me.Controls.Add(BBPCCheckBox) + Me.Controls.Add(CCCheckBox) + Me.Controls.Add(AutoStepCheckBox) + Me.Controls.Add(StepTextBox) + Me.Controls.Add(CollSensTextBox) + Me.Controls.Add(ExtractDirCheckBox) + Me.Controls.Add(AxisComboBox) + Me.Controls.Add(XLSTextBox) + Me.Controls.Add(OKButton) + + Me.ShowDialog() + End Sub + + Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OKButton.Click + iBoundingBoxCode = BBCodeComboBox.SelectedItem + bBoundingBoxProjectionCheck = BBPCCheckBox.Checked + bConnectivityCheck = CCCheckBox.Checked + bAutomaticStep = AutoStepCheckBox.Checked + dCollSens = CDbl(CollSensTextBox.Text) + bChooseExtractionDirection = ExtractDirCheckBox.Checked + intJ = AxisComboBox.SelectedItem + xlsFileName = XLSTextBox.Text + Debug.Print("Parameters accepted") + Me.Hide() + Me.CatMain() + End Sub + End Class + diff --git a/CatiaNetTest/Form1.Designer.vb b/CatiaNetTest/Form1.Designer.vb index c8a93736a9aff1c5b2c76a2b9686ceb6a102e8f3..194e38fedf0494efec4a24e819c53bc989666274 100644 --- a/CatiaNetTest/Form1.Designer.vb +++ b/CatiaNetTest/Form1.Designer.vb @@ -118,7 +118,7 @@ Partial Class Form1 Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.Label1) Me.Name = "Form1" - Me.Text = "CATIA .NET TEST" + Me.Text = "CATIA .NET" Me.ResumeLayout(False) Me.PerformLayout() diff --git a/CatiaNetTest/Form1.vb b/CatiaNetTest/Form1.vb index 8fe82d64edd9f3febd8d9a049e64500c76b49906..23cc7fa4b6bf0d4850c10b8834b3288675d25c07 100644 --- a/CatiaNetTest/Form1.vb +++ b/CatiaNetTest/Form1.vb @@ -33,7 +33,7 @@ Public Class Form1 Dim myAssemblyTiers As AssemblyTiers2 = New AssemblyTiers2() Try - myAssemblyTiers.CatMain() + myAssemblyTiers.ShowForm() Catch ex As Exception Debug.WriteLine(ex.ToString()) End Try diff --git a/CatiaNetTest/bin/Debug/CatiaNetTest.exe b/CatiaNetTest/bin/Debug/CatiaNetTest.exe index e09982ee09f61a910f46adf8c13a9e2a75aef273..c3ac95e63787de3995e67465a3f9fee091463de0 100644 Binary files a/CatiaNetTest/bin/Debug/CatiaNetTest.exe and b/CatiaNetTest/bin/Debug/CatiaNetTest.exe differ diff --git a/CatiaNetTest/bin/Debug/CatiaNetTest.pdb b/CatiaNetTest/bin/Debug/CatiaNetTest.pdb index 10b8f13e3bd8bf2e5bad681d59d90b83f5d5131a..76f93b5c5d754a065f98f46d404716637806907c 100644 Binary files a/CatiaNetTest/bin/Debug/CatiaNetTest.pdb and b/CatiaNetTest/bin/Debug/CatiaNetTest.pdb differ diff --git a/CatiaNetTest/obj/Debug/CatiaNetTest.exe b/CatiaNetTest/obj/Debug/CatiaNetTest.exe index e09982ee09f61a910f46adf8c13a9e2a75aef273..c3ac95e63787de3995e67465a3f9fee091463de0 100644 Binary files a/CatiaNetTest/obj/Debug/CatiaNetTest.exe and b/CatiaNetTest/obj/Debug/CatiaNetTest.exe differ diff --git a/CatiaNetTest/obj/Debug/CatiaNetTest.pdb b/CatiaNetTest/obj/Debug/CatiaNetTest.pdb index 10b8f13e3bd8bf2e5bad681d59d90b83f5d5131a..76f93b5c5d754a065f98f46d404716637806907c 100644 Binary files a/CatiaNetTest/obj/Debug/CatiaNetTest.pdb and b/CatiaNetTest/obj/Debug/CatiaNetTest.pdb differ diff --git a/CatiaNetTest/obj/Debug/CatiaNetTest.vbproj.GenerateResource.Cache b/CatiaNetTest/obj/Debug/CatiaNetTest.vbproj.GenerateResource.Cache index 594ce36497884ed1df0d337248f4c486c2c79d72..dcb032f0beb9bf25d70e0cd9fc0fa8daeb14e159 100644 Binary files a/CatiaNetTest/obj/Debug/CatiaNetTest.vbproj.GenerateResource.Cache and b/CatiaNetTest/obj/Debug/CatiaNetTest.vbproj.GenerateResource.Cache differ diff --git a/CatiaNetTest/obj/Debug/CatiaNetTest.vbproj.ResolveComReference.cache b/CatiaNetTest/obj/Debug/CatiaNetTest.vbproj.ResolveComReference.cache index f9fd5b2db8d07a16c65f5d449088c3156f85779a..93db3aeff60771bd0b6abbcb75991c7082b23923 100644 Binary files a/CatiaNetTest/obj/Debug/CatiaNetTest.vbproj.ResolveComReference.cache and b/CatiaNetTest/obj/Debug/CatiaNetTest.vbproj.ResolveComReference.cache differ diff --git a/CatiaNetTest/obj/Debug/CatiaNetTest.vbprojAssemblyReference.cache b/CatiaNetTest/obj/Debug/CatiaNetTest.vbprojAssemblyReference.cache index 7e0968d4938a6fd3504f231b9b910fa003dd79d5..6eb141be4bee0ee5c65bd86c64f00139b3982321 100644 Binary files a/CatiaNetTest/obj/Debug/CatiaNetTest.vbprojAssemblyReference.cache and b/CatiaNetTest/obj/Debug/CatiaNetTest.vbprojAssemblyReference.cache differ