Frame works for all recesses and how it is cut is optimized
This commit is contained in:
parent
3d3801c974
commit
1584a2e550
Binary file not shown.
|
|
@ -3,10 +3,20 @@ Public Class Individual_Frame_3D
|
|||
Private Shared designName As String
|
||||
Public Shared Sub Build_Frame(gratingParameters As DataRow, parentID As Integer)
|
||||
Dim frameDT As New DataTable
|
||||
frameDT = Generate_Frame_Data(gratingParameters)
|
||||
frameDT = Generate_FrameData(gratingParameters)
|
||||
|
||||
Dim sideFrameLengths As New Dictionary(Of String, Integer)
|
||||
For i = 0 To frameDT.Rows.Count - 1
|
||||
If frameDT.Rows(i)("TYPE") = "SIDE" Then
|
||||
sideFrameLengths.Add("Frame " & sideFrameLengths.Count + 1, frameDT.Rows(i)("LENGTH"))
|
||||
End If
|
||||
Next
|
||||
Dim cuttingList As New Dictionary(Of Integer, Integer())
|
||||
cuttingList = Generate_CuttingList(frameDT, sideFrameLengths)
|
||||
|
||||
Dim inst_ As Integer
|
||||
|
||||
Dim sideFrame As Integer = 0
|
||||
For i = 0 To frameDT.Rows.Count - 1
|
||||
Dim HLCtName As String
|
||||
If frameDT.Rows(i)("TYPE") = "CORNER" Then
|
||||
|
|
@ -23,14 +33,27 @@ Public Class Individual_Frame_3D
|
|||
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, frameDT.Rows(i)("OFFSET_L"))
|
||||
|
||||
If frameDT.Rows(i)("TYPE") = "SIDE" Then
|
||||
ExternalClass.modify_parameter_value("DP_CUTOFFSET1", inst_, 0)
|
||||
ExternalClass.modify_parameter_value("DP_CUTOFFSET2", inst_, 2000 - frameDT.Rows(i)("LENGTH"))
|
||||
sideFrame += 1
|
||||
Dim cutOffset1 As Integer = 0
|
||||
For j = 0 To cuttingList.Count - 1
|
||||
For k = 0 To cuttingList.ElementAt(j).Value.Count - 1
|
||||
If sideFrame = cuttingList.ElementAt(j).Value(k) Then
|
||||
For l = 1 To k
|
||||
cutOffset1 += sideFrameLengths("Frame " & cuttingList.ElementAt(j).Value(l - 1))
|
||||
Next
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
|
||||
|
||||
ExternalClass.modify_parameter_value("DP_CUTOFFSET1", inst_, cutOffset1)
|
||||
ExternalClass.modify_parameter_value("DP_CUTOFFSET2", inst_, 2000 - frameDT.Rows(i)("LENGTH") - cutOffset1)
|
||||
End If
|
||||
Next
|
||||
|
||||
End Sub
|
||||
|
||||
Private Shared Function Generate_Frame_Data(gratingParameters As DataRow)
|
||||
Private Shared Function Generate_FrameData(gratingParameters As DataRow)
|
||||
Dim DT As New DataTable
|
||||
DT.Columns.Add("TYPE", GetType(String))
|
||||
DT.Columns.Add("LENGTH", GetType(Integer))
|
||||
|
|
@ -112,6 +135,15 @@ Public Class Individual_Frame_3D
|
|||
corners.Add(Data.gratingPoints.Rows(i)("NAME"), False)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
For i = 0 To Data.gratingPoints.Rows.Count - 1
|
||||
Dim i2 As Integer
|
||||
If i = Data.gratingPoints.Rows.Count - 1 Then
|
||||
i2 = 0
|
||||
Else
|
||||
i2 = i + 1
|
||||
End If
|
||||
|
||||
Dim sideFrame As Boolean = False
|
||||
If Data.gratingPoints.Rows(i)("X") = Data.gratingPoints.Rows(i2)("X") Then
|
||||
|
|
@ -128,66 +160,127 @@ Public Class Individual_Frame_3D
|
|||
DTRow = DT.NewRow
|
||||
DTRow("TYPE") = "SIDE"
|
||||
|
||||
Dim missingCorner1 As Integer = 0
|
||||
Dim missingCorner2 As Integer = 0
|
||||
|
||||
Dim extraCorner1 As Integer = 0
|
||||
Dim extraCorner2 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
|
||||
If Data.gratingPoints.Rows(i)("NAME").substring(0, 1) = "P" AndAlso Data.gratingPoints.Rows(i2)("NAME").substring(0, 1) = "P" Then
|
||||
numOfP = 2
|
||||
If corners(Data.gratingPoints.Rows(i)("NAME")) = False Then
|
||||
extraCorner1 = 200
|
||||
End If
|
||||
|
||||
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("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
|
||||
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("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
|
||||
If corners(Data.gratingPoints.Rows(i2)("NAME")) = False Then
|
||||
extraCorner2 = 200
|
||||
End If
|
||||
DTRow("ROTATION") = 360 - DTRow("SIDE") * 90
|
||||
|
||||
If DTRow("LENGTH") >= 125 Then
|
||||
DT.Rows.Add(DTRow)
|
||||
ElseIf Data.gratingPoints.Rows(i)("NAME").substring(0, 1) = "P" Then
|
||||
numOfP = 1
|
||||
If corners(Data.gratingPoints.Rows(i)("NAME")) = False Then
|
||||
extraCorner1 = 200
|
||||
End If
|
||||
ElseIf Data.gratingPoints.Rows(i2)("NAME").substring(0, 1) = "P" Then
|
||||
numOfP = 1
|
||||
If corners(Data.gratingPoints.Rows(i2)("NAME")) = False Then
|
||||
extraCorner2 = 200
|
||||
End If
|
||||
End If
|
||||
|
||||
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 + extraCorner1 + extraCorner2
|
||||
If Data.gratingPoints.Rows(i2)("NAME").substring(0, 1) = "P" Then
|
||||
DTRow("OFFSET_W") = 210 - extraCorner2
|
||||
Else
|
||||
DTRow("OFFSET_W") = Data.gratingW / 2 + 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 + extraCorner1 + extraCorner2
|
||||
If Data.gratingPoints.Rows(i)("NAME").substring(0, 1) = "P" Then
|
||||
DTRow("OFFSET_W") = DTRow("LENGTH") + 210 - extraCorner1
|
||||
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
|
||||
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 + extraCorner1 + extraCorner2
|
||||
DTRow("OFFSET_W") = 0
|
||||
If Data.gratingPoints.Rows(i2)("NAME").substring(0, 1) = "P" Then
|
||||
DTRow("OFFSET_L") = 210 - extraCorner2
|
||||
Else
|
||||
DTRow("OFFSET_L") = Data.gratingL / 2 + Data.gratingPoints.Rows(i2)("X") * 1000 + 10
|
||||
End If
|
||||
Else
|
||||
DTRow("SIDE") = 2
|
||||
DTRow("LENGTH") = (Data.gratingPoints.Rows(i2)("X") - Data.gratingPoints.Rows(i)("X")) * 1000 - 20 - numOfP * 200 + extraCorner1 + extraCorner2
|
||||
DTRow("OFFSET_W") = gratingParameters("WIDTH")
|
||||
If Data.gratingPoints.Rows(i)("NAME").substring(0, 1) = "P" Then
|
||||
DTRow("OFFSET_L") = DTRow("LENGTH") + 210 - extraCorner1
|
||||
Else
|
||||
DTRow("OFFSET_L") = DTRow("LENGTH") + Data.gratingL / 2 + Data.gratingPoints.Rows(i)("X") * 1000 + 10
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
DTRow("ROTATION") = 360 - DTRow("SIDE") * 90
|
||||
|
||||
If DTRow("LENGTH") >= 125 Then
|
||||
DT.Rows.Add(DTRow)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
Return DT
|
||||
End Function
|
||||
|
||||
Private Shared Function Generate_CuttingList(frameDT As DataTable, sideFrameLengths As Dictionary(Of String, Integer))
|
||||
Dim frameLengths As New Dictionary(Of String, Integer)
|
||||
For i = 0 To sideFrameLengths.Count - 1
|
||||
frameLengths.Add(sideFrameLengths.ElementAt(i).Key, sideFrameLengths.ElementAt(i).Value)
|
||||
Next
|
||||
|
||||
Dim cuttingList As New Dictionary(Of Integer, Integer())
|
||||
|
||||
While frameLengths.Count > 0
|
||||
Dim frameCutList As New Dictionary(Of String, Integer)
|
||||
|
||||
frameCutList.Add(frameLengths.ElementAt(0).Key, frameLengths.ElementAt(0).Value)
|
||||
frameLengths.Remove(frameLengths.ElementAt(0).Key)
|
||||
|
||||
For i = 0 To 100
|
||||
Dim lengthRemaining As Integer = 2000
|
||||
For j = 0 To frameCutList.Count - 1
|
||||
lengthRemaining -= frameCutList.ElementAt(j).Value
|
||||
Next
|
||||
|
||||
Dim restLength As Integer = 2000
|
||||
Dim frameID As String = ""
|
||||
For j = 0 To frameLengths.Count - 1
|
||||
If lengthRemaining - frameLengths.ElementAt(j).Value > 0 AndAlso lengthRemaining - frameLengths.ElementAt(j).Value < restLength Then
|
||||
restLength = lengthRemaining - frameLengths.ElementAt(j).Value
|
||||
frameID = frameLengths.ElementAt(j).Key
|
||||
End If
|
||||
Next
|
||||
|
||||
If frameID = "" Then
|
||||
Exit For
|
||||
Else
|
||||
frameCutList.Add(frameID, frameLengths(frameID))
|
||||
frameLengths.Remove(frameID)
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim cutFrameIDs(frameCutList.Count - 1) As Integer
|
||||
For i = 0 To frameCutList.Count - 1
|
||||
cutFrameIDs(i) = frameCutList.ElementAt(i).Key.Split(" ")(1)
|
||||
Next
|
||||
|
||||
cuttingList.Add(cuttingList.Count + 1, cutFrameIDs)
|
||||
End While
|
||||
|
||||
|
||||
Return cuttingList
|
||||
End Function
|
||||
End Class
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ Public Class Model_3D_Fill
|
|||
designName = designTable.rows(0)("designName")
|
||||
groupClass.InstantiateGroup(designName, grNr, "START")
|
||||
|
||||
'Check_Interference()
|
||||
Check_Interference()
|
||||
Recess_Indent()
|
||||
Delete_Obsolete()
|
||||
End Sub
|
||||
|
|
@ -611,21 +611,24 @@ Public Class Model_3D_Fill
|
|||
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
|
||||
Dim CompArray() As SldWorks.Component2
|
||||
Dim vCompArray
|
||||
Dim vIntCompArray
|
||||
Dim vIntFaceArray
|
||||
|
||||
Dim interfering
|
||||
|
||||
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")
|
||||
'CompArray = swAssy.GetComponents(True)
|
||||
'For i = 1 To components.length - 1
|
||||
' CompArray(0) = swAssy.GetComponentByName("Part2^Assem1-1")
|
||||
'Next
|
||||
|
||||
vCompArray = components
|
||||
swAssy.ToolsCheckInterference2(components.length, vCompArray, True, vIntCompArray, vIntFaceArray)
|
||||
swAssy.ToolsCheckInterference2(components.length, (vCompArray), interfering, vIntCompArray, vIntFaceArray)
|
||||
|
||||
|
||||
Dim Bodies(UBound(vIntFaceArray)) As Object
|
||||
|
|
|
|||
Loading…
Reference in New Issue