diff --git a/HLCt/Parts/START.SLDPRT b/HLCt/Parts/START.SLDPRT index fb2df7b..dc2aec7 100644 Binary files a/HLCt/Parts/START.SLDPRT and b/HLCt/Parts/START.SLDPRT differ diff --git a/Wardrobe/SolidWorks/Multiple_Drawing.vb b/Wardrobe/SolidWorks/Multiple_Drawing.vb index a25859f..bf882ad 100644 --- a/Wardrobe/SolidWorks/Multiple_Drawing.vb +++ b/Wardrobe/SolidWorks/Multiple_Drawing.vb @@ -2,7 +2,7 @@ Public Class Multiple_Drawing Public Shared Sub Create_Models_For_Drawing() - Dim gratingsPointsDS As DataSet = Create_GreatingPoints() + Dim gratingsPointsDS As DataSet = Create_GratingPoints() Dim gratingHeight As Decimal = User_Input.gratingHeight / 1000 @@ -105,7 +105,7 @@ Public Class Multiple_Drawing longstatus = Model.SaveAs3(Settings.folderPaths("object_" & Data.objectNum & "_models3D_gratings_sw_support") & "\simplified_grating_assembly.SLDASM", 0, 0) End Sub - Private Shared Function Create_GreatingPoints() + Private Shared Function Create_GratingPoints() Dim pointsDS As New DataSet Dim numOfGratings As Integer = Grating_Fill.numOfVertical * Grating_Fill.numOfHorizontal @@ -176,6 +176,87 @@ Public Class Multiple_Drawing Next ' --- Add recess points --- + Dim recessPointsDT As New DataTable + recessPointsDT.Columns.Add("NAME", GetType(String)) + recessPointsDT.Columns.Add("TYPE", GetType(String)) + recessPointsDT.Columns.Add("SIDE", GetType(Integer)) + recessPointsDT.Columns.Add("X", GetType(Double)) + recessPointsDT.Columns.Add("Y", GetType(Double)) + + For j = 1 To 4 + For Each DR As DataRow In Data.gratingPoints.Rows + Dim recessDR As DataRow = recessPointsDT.NewRow() + recessDR("NAME") = DR("NAME") + recessDR("SIDE") = j + recessDR("X") = DR("X") + recessDR("Y") = DR("Y") + Dim pointName As String = DR("NAME") + If pointName.Substring(0, 2) = "CA" Then + recessDR("TYPE") = "Corner Angle" + ElseIf pointName.Substring(0, 2) = "CR" Then + recessDR("TYPE") = "Corner Rectangle" + ElseIf pointName.Substring(0, 2) = "CS" Then + recessDR("TYPE") = "Side Rectangle" + Else + Continue For + End If + + If j = 1 Then + If DR("Y") = pointsDT.Rows(0)("Y") Then + If DR("X") >= pointsDT.Rows(0)("X") AndAlso DR("X") <= pointsDT.Rows(1)("X") Then + recessPointsDT.Rows.Add(recessDR) + End If + End If + ElseIf j = 2 Then + If DR("X") = pointsDT.Rows(1)("X") Then + If DR("Y") <= pointsDT.Rows(1)("Y") AndAlso DR("Y") >= pointsDT.Rows(2)("Y") Then + recessPointsDT.Rows.Add(recessDR) + End If + End If + ElseIf j = 3 Then + If DR("Y") = pointsDT.Rows(2)("Y") Then + If DR("X") <= pointsDT.Rows(2)("X") AndAlso DR("X") >= pointsDT.Rows(3)("X") Then + recessPointsDT.Rows.Add(recessDR) + End If + End If + Else + If DR("X") = pointsDT.Rows(3)("X") Then + If DR("Y") >= pointsDT.Rows(3)("Y") AndAlso DR("Y") <= pointsDT.Rows(0)("Y") Then + recessPointsDT.Rows.Add(recessDR) + End If + End If + End If + Next + Next + + For Each DR As DataRow In recessPointsDT.Rows + If DR("TYPE") = "Corner Angle" Then + Dim pointName As String = DR("NAME") + If pointName.Split("_")(1) = 1 Then + Dim DR3 As DataRow = pointsDT.NewRow() + DR3("NAME") = DR("NAME") + DR3("TYPE") = "Recess CA" + DR3("X") = DR("X") + DR3("Y") = DR("Y") + Dim index As Integer = Get_RowIndex(pointsDT, DR) + + + pointsDT.Rows.InsertAt(DR3, index + 1) + + Try + pointsDT.Rows.RemoveAt(index + 2) + Catch ex As Exception + pointsDT.Rows.RemoveAt(0) + End Try + + 'Check if remove next point aswell (If angle crosses more than one grating) + Else + + End If + End If + + + Next @@ -186,4 +267,56 @@ Public Class Multiple_Drawing Return pointsDS End Function + + Private Shared Function Get_RowIndex(pDT As DataTable, rpDR As DataRow) + + Dim rowName As String = "" + If rpDR("SIDE") = 1 Then + Dim sidePoints = pDT.Select("Y = '" & rpDR("Y") & "'") + For Each DR2 As DataRow In sidePoints + If DR2("X") < rpDR("X") Then + rowName = DR2("NAME") + Else + Exit For + End If + Next + ElseIf rpDR("SIDE") = 2 Then + Dim sidePoints = pDT.Select("X = '" & rpDR("X") & "'") + For Each DR2 As DataRow In sidePoints + If DR2("Y") > rpDR("Y") Then + rowName = DR2("NAME") + Else + Exit For + End If + Next + ElseIf rpDR("SIDE") = 3 Then + Dim sidePoints = pDT.Select("Y = '" & rpDR("Y") & "'") + For Each DR2 As DataRow In sidePoints + If DR2("X") > rpDR("X") Then + rowName = DR2("NAME") + Else + Exit For + End If + Next + Else + Dim sidePoints = pDT.Select("X = '" & rpDR("X") & "'") + For Each DR2 As DataRow In sidePoints + If DR2("Y") < rpDR("Y") Then + rowName = DR2("NAME") + Else + Exit For + End If + Next + End If + + Dim index As Integer = 0 + For j = 0 To pDT.Rows.Count - 1 + If pDT.Rows(j)("NAME") = rowName Then + index = j + Exit For + End If + Next + + Return index + End Function End Class