From 3d3801c9747bed427e708a04800a7c2053ccb657 Mon Sep 17 00:00:00 2001 From: Mans Date: Mon, 22 Mar 2021 13:43:14 +0100 Subject: [PATCH] Frame fix --- HLCt/Parts/~$START.SLDPRT | Bin 0 -> 6 bytes Wardrobe/GUI/Individual.vb | 2 +- Wardrobe/SolidWorks/Individual_Frame_3D.vb | 175 +++++++++++++-------- Wardrobe/SolidWorks/Model_3D_Fill.vb | 37 +++++ 4 files changed, 150 insertions(+), 64 deletions(-) create mode 100644 HLCt/Parts/~$START.SLDPRT diff --git a/HLCt/Parts/~$START.SLDPRT b/HLCt/Parts/~$START.SLDPRT new file mode 100644 index 0000000000000000000000000000000000000000..b07f2ee735073c92fc341c66f5066b7db22efc93 GIT binary patch literal 6 NcmazjNG(cX000O00t5g6 literal 0 HcmV?d00001 diff --git a/Wardrobe/GUI/Individual.vb b/Wardrobe/GUI/Individual.vb index 2a6ec0c..71accf2 100644 --- a/Wardrobe/GUI/Individual.vb +++ b/Wardrobe/GUI/Individual.vb @@ -249,7 +249,7 @@ Public Class Individual Model_3D_Fill.BuildGrid() Else - 'Model_3D.BuildGrating() + Model_3D.BuildGrating() Drawing.Create_Model_For_Drawing() End If End Sub diff --git a/Wardrobe/SolidWorks/Individual_Frame_3D.vb b/Wardrobe/SolidWorks/Individual_Frame_3D.vb index 5fd6b07..59b333f 100644 --- a/Wardrobe/SolidWorks/Individual_Frame_3D.vb +++ b/Wardrobe/SolidWorks/Individual_Frame_3D.vb @@ -40,36 +40,79 @@ Public Class Individual_Frame_3D DT.Columns.Add("OFFSET_W", GetType(Integer)) DT.Columns.Add("OFFSET_L", GetType(Integer)) Dim DTRow As DataRow + + Dim corners As New Dictionary(Of String, Boolean) + For i = 0 To Data.gratingPoints.Rows.Count - 1 - If Data.gratingPoints.Rows(i)("RECESS OK") Then - DTRow = DT.NewRow - DTRow("TYPE") = "CORNER" - DTRow("CORNER") = Data.gratingPoints.Rows(i)("QUADRANT") - DTRow("ROTATION") = (Data.gratingPoints.Rows(i)("QUADRANT") - 1) * 90 - If DTRow("CORNER") = 1 Then - DTRow("OFFSET_W") = gratingParameters("WIDTH") - DTRow("OFFSET_L") = 0 - ElseIf DTRow("CORNER") = 2 Then - DTRow("OFFSET_W") = gratingParameters("WIDTH") - DTRow("OFFSET_L") = gratingParameters("LENGTH") - ElseIf DTRow("CORNER") = 3 Then - DTRow("OFFSET_W") = 0 - DTRow("OFFSET_L") = gratingParameters("LENGTH") - Else - DTRow("OFFSET_W") = 0 - DTRow("OFFSET_L") = 0 - End If - DT.Rows.Add(DTRow) + Dim i2, i0 As Integer + If i = 0 Then + i0 = Data.gratingPoints.Rows.Count - 1 + Else + i0 = i - 1 End If - - Dim i2 As Integer If i = Data.gratingPoints.Rows.Count - 1 Then i2 = 0 Else i2 = i + 1 End If + If Data.gratingPoints.Rows(i)("RECESS OK") Then + Dim firstOK, secondOK As Boolean + + If Data.gratingPoints.Rows(i)("X") = Data.gratingPoints.Rows(i0)("X") Then + If Math.Abs(Data.gratingPoints.Rows(i)("Y") - Data.gratingPoints.Rows(i0)("Y")) * 1000 >= 210 Then + firstOK = True + Else + firstOK = False + End If + Else + If Math.Abs(Data.gratingPoints.Rows(i)("X") - Data.gratingPoints.Rows(i0)("X")) * 1000 >= 210 Then + firstOK = True + Else + firstOK = False + End If + End If + + If Data.gratingPoints.Rows(i)("X") = Data.gratingPoints.Rows(i2)("X") Then + If Math.Abs(Data.gratingPoints.Rows(i)("Y") - Data.gratingPoints.Rows(i2)("Y")) * 1000 >= 210 Then + secondOK = True + Else + secondOK = False + End If + Else + If Math.Abs(Data.gratingPoints.Rows(i)("X") - Data.gratingPoints.Rows(i2)("X")) * 1000 >= 210 Then + secondOK = True + Else + secondOK = False + End If + End If + + If firstOK = True AndAlso secondOK = True Then + corners.Add(Data.gratingPoints.Rows(i)("NAME"), True) + DTRow = DT.NewRow + DTRow("TYPE") = "CORNER" + DTRow("CORNER") = Data.gratingPoints.Rows(i)("QUADRANT") + DTRow("ROTATION") = (Data.gratingPoints.Rows(i)("QUADRANT") - 1) * 90 + If DTRow("CORNER") = 1 Then + DTRow("OFFSET_W") = gratingParameters("WIDTH") + DTRow("OFFSET_L") = 0 + ElseIf DTRow("CORNER") = 2 Then + DTRow("OFFSET_W") = gratingParameters("WIDTH") + DTRow("OFFSET_L") = gratingParameters("LENGTH") + ElseIf DTRow("CORNER") = 3 Then + DTRow("OFFSET_W") = 0 + DTRow("OFFSET_L") = gratingParameters("LENGTH") + Else + DTRow("OFFSET_W") = 0 + DTRow("OFFSET_L") = 0 + End If + DT.Rows.Add(DTRow) + Else + corners.Add(Data.gratingPoints.Rows(i)("NAME"), False) + End If + End If + Dim sideFrame As Boolean = False If Data.gratingPoints.Rows(i)("X") = Data.gratingPoints.Rows(i2)("X") Then If Data.gratingPoints.Rows(i)("X") = Data.grossAreaPoints.Rows(0)("X") Or Data.gratingPoints.Rows(i)("X") = Data.grossAreaPoints.Rows(1)("X") Then @@ -85,58 +128,64 @@ Public Class Individual_Frame_3D DTRow = DT.NewRow DTRow("TYPE") = "SIDE" + Dim missingCorner1 As Integer = 0 + Dim missingCorner2 As Integer = 0 + Dim numOfP As Integer = 0 - If Data.gratingPoints.Rows(i)("NAME").substring(0, 1) = "P" AndAlso Data.gratingPoints.Rows(i2)("NAME").substring(0, 1) = "P" Then - numOfP = 2 - ElseIf Data.gratingPoints.Rows(i)("NAME").substring(0, 1) = "P" Or Data.gratingPoints.Rows(i2)("NAME").substring(0, 1) = "P" Then - numOfP = 1 - End If + If Data.gratingPoints.Rows(i)("NAME").substring(0, 1) = "P" AndAlso Data.gratingPoints.Rows(i2)("NAME").substring(0, 1) = "P" Then + numOfP = 2 - If Data.gratingPoints.Rows(i)("X") = Data.gratingPoints.Rows(i2)("X") Then - If Data.gratingPoints.Rows(i)("Y") > Data.gratingPoints.Rows(i2)("Y") Then - DTRow("SIDE") = 3 - DTRow("LENGTH") = (Data.gratingPoints.Rows(i)("Y") - Data.gratingPoints.Rows(i2)("Y")) * 1000 - 20 - numOfP * 200 - If Data.gratingPoints.Rows(i2)("NAME").substring(0, 1) = "P" Then - DTRow("OFFSET_W") = 210 - Else - DTRow("OFFSET_W") = Data.gratingW / 2 - Math.Abs(Data.gratingPoints.Rows(i2)("Y")) * 1000 + 10 - End If - DTRow("OFFSET_L") = gratingParameters("LENGTH") - Else - DTRow("SIDE") = 1 - DTRow("LENGTH") = (Data.gratingPoints.Rows(i2)("Y") - Data.gratingPoints.Rows(i)("Y")) * 1000 - 20 - numOfP * 200 - If Data.gratingPoints.Rows(i)("NAME").substring(0, 1) = "P" Then - DTRow("OFFSET_W") = DTRow("LENGTH") + 210 - Else - DTRow("OFFSET_W") = DTRow("LENGTH") + Data.gratingW / 2 - Math.Abs(Data.gratingPoints.Rows(i)("Y")) * 1000 + 10 - End If - DTRow("OFFSET_L") = 0 + ElseIf Data.gratingPoints.Rows(i)("NAME").substring(0, 1) = "P" Or Data.gratingPoints.Rows(i2)("NAME").substring(0, 1) = "P" Then + numOfP = 1 End If - Else - If Data.gratingPoints.Rows(i)("X") > Data.gratingPoints.Rows(i2)("X") Then - DTRow("SIDE") = 4 - DTRow("LENGTH") = (Data.gratingPoints.Rows(i)("X") - Data.gratingPoints.Rows(i2)("X")) * 1000 - 20 - numOfP * 200 - DTRow("OFFSET_W") = 0 - If Data.gratingPoints.Rows(i2)("NAME").substring(0, 1) = "P" Then - DTRow("OFFSET_L") = 210 + + If Data.gratingPoints.Rows(i)("X") = Data.gratingPoints.Rows(i2)("X") Then + If Data.gratingPoints.Rows(i)("Y") > Data.gratingPoints.Rows(i2)("Y") Then + DTRow("SIDE") = 3 + DTRow("LENGTH") = (Data.gratingPoints.Rows(i)("Y") - Data.gratingPoints.Rows(i2)("Y")) * 1000 - 20 - numOfP * 200 + If Data.gratingPoints.Rows(i2)("NAME").substring(0, 1) = "P" Then + DTRow("OFFSET_W") = 210 + Else + DTRow("OFFSET_W") = Data.gratingW / 2 + Data.gratingPoints.Rows(i2)("Y") * 1000 + 10 + End If + DTRow("OFFSET_L") = gratingParameters("LENGTH") Else - DTRow("OFFSET_L") = Data.gratingL / 2 - Math.Abs(Data.gratingPoints.Rows(i2)("X")) * 1000 + 10 + DTRow("SIDE") = 1 + DTRow("LENGTH") = (Data.gratingPoints.Rows(i2)("Y") - Data.gratingPoints.Rows(i)("Y")) * 1000 - 20 - numOfP * 200 + If Data.gratingPoints.Rows(i)("NAME").substring(0, 1) = "P" Then + DTRow("OFFSET_W") = DTRow("LENGTH") + 210 + Else + DTRow("OFFSET_W") = DTRow("LENGTH") + Data.gratingW / 2 + Data.gratingPoints.Rows(i)("Y") * 1000 + 10 + End If + DTRow("OFFSET_L") = 0 End If Else - DTRow("SIDE") = 2 - DTRow("LENGTH") = (Data.gratingPoints.Rows(i2)("X") - Data.gratingPoints.Rows(i)("X")) * 1000 - 20 - numOfP * 200 - DTRow("OFFSET_W") = gratingParameters("WIDTH") - If Data.gratingPoints.Rows(i)("NAME").substring(0, 1) = "P" Then - DTRow("OFFSET_L") = DTRow("LENGTH") + 210 + If Data.gratingPoints.Rows(i)("X") > Data.gratingPoints.Rows(i2)("X") Then + DTRow("SIDE") = 4 + DTRow("LENGTH") = (Data.gratingPoints.Rows(i)("X") - Data.gratingPoints.Rows(i2)("X")) * 1000 - 20 - numOfP * 200 + DTRow("OFFSET_W") = 0 + If Data.gratingPoints.Rows(i2)("NAME").substring(0, 1) = "P" Then + DTRow("OFFSET_L") = 210 + Else + DTRow("OFFSET_L") = Data.gratingL / 2 + Data.gratingPoints.Rows(i2)("X") * 1000 + 10 + End If Else - DTRow("OFFSET_L") = DTRow("LENGTH") + Data.gratingL / 2 - Math.Abs(Data.gratingPoints.Rows(i)("X")) * 1000 + 10 + DTRow("SIDE") = 2 + DTRow("LENGTH") = (Data.gratingPoints.Rows(i2)("X") - Data.gratingPoints.Rows(i)("X")) * 1000 - 20 - numOfP * 200 + DTRow("OFFSET_W") = gratingParameters("WIDTH") + If Data.gratingPoints.Rows(i)("NAME").substring(0, 1) = "P" Then + DTRow("OFFSET_L") = DTRow("LENGTH") + 210 + Else + DTRow("OFFSET_L") = DTRow("LENGTH") + Data.gratingL / 2 + Data.gratingPoints.Rows(i)("X") * 1000 + 10 + End If End If End If - End If - DTRow("ROTATION") = 360 - DTRow("SIDE") * 90 - DT.Rows.Add(DTRow) - End If + DTRow("ROTATION") = 360 - DTRow("SIDE") * 90 + If DTRow("LENGTH") >= 125 Then + DT.Rows.Add(DTRow) + End If + End If Next Return DT diff --git a/Wardrobe/SolidWorks/Model_3D_Fill.vb b/Wardrobe/SolidWorks/Model_3D_Fill.vb index 8185be5..d78e269 100644 --- a/Wardrobe/SolidWorks/Model_3D_Fill.vb +++ b/Wardrobe/SolidWorks/Model_3D_Fill.vb @@ -1,4 +1,5 @@ Imports XCCLibrary +Imports SldWorks Public Class Model_3D_Fill Private Shared designName As String @@ -54,6 +55,7 @@ Public Class Model_3D_Fill designName = designTable.rows(0)("designName") groupClass.InstantiateGroup(designName, grNr, "START") + 'Check_Interference() Recess_Indent() Delete_Obsolete() End Sub @@ -603,4 +605,39 @@ Public Class Model_3D_Fill Return True End If End Function + + Private Shared Sub Check_Interference() ' Test Albins mocro för interference + + Dim swApp As SldWorks.SldWorks + Dim swModel As SldWorks.ModelDoc2 + Dim swAssy As SldWorks.AssemblyDoc + Dim CompArray(1) As SldWorks.Component2 + Dim vCompArray As Object + Dim vIntCompArray As Object + Dim vIntFaceArray As Object + + swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks) + swModel = swApp.ActiveDoc + swAssy = swModel + Dim components = swAssy.GetComponents(True) + 'For i = 0 To components.count - 1 + ' CompArray(i) = swAssy.GetComponentByName("Part2^Assem1-1") + 'Next + + vCompArray = components + swAssy.ToolsCheckInterference2(components.length, vCompArray, True, vIntCompArray, vIntFaceArray) + + + Dim Bodies(UBound(vIntFaceArray)) As Object + Dim BodyNames(UBound(vIntFaceArray)) As String + Dim CompNames(UBound(vIntFaceArray)) As String + + For i = 0 To UBound(vIntFaceArray) + + Bodies(i) = vIntFaceArray(i).GetBody + BodyNames(i) = Bodies(i).Name + CompNames(i) = vIntCompArray(i).Name2 + + Next + End Sub End Class