Weland drawing template, adjust scale auto

This commit is contained in:
Mans 2021-02-11 13:46:48 +01:00
parent 0d0f436aa2
commit 49e294e498
23 changed files with 52 additions and 16 deletions

View File

@ -1,6 +1,6 @@
Public Class GUI_Gratings_Data Public Class GUI_Gratings_Data
Public Shared gratingMaxW As Decimal = 1000 Public Shared gratingMaxW As Integer = 1000
Public Shared gratingMaxL As Decimal = 1000 Public Shared gratingMaxL As Integer = 1000
Private Shared gratingType, gratingMaterial, gratingMesh, gratingName As String Private Shared gratingType, gratingMaterial, gratingMesh, gratingName As String
Private Shared gratingSerrated As Boolean = False Private Shared gratingSerrated As Boolean = False
@ -337,9 +337,9 @@
Public Shared Sub WidthChanged(sender As Object, e As EventArgs) Public Shared Sub WidthChanged(sender As Object, e As EventArgs)
If GUI.ComboBox_Width.Text <> "" Then If GUI.ComboBox_Width.Text <> "" Then
If CDec(GUI.ComboBox_Width.Text) >= GUI.ComboBox_Width.Items(GUI.ComboBox_Width.Items.Count - 1) AndAlso If CInt(GUI.ComboBox_Width.Text) >= GUI.ComboBox_Width.Items(GUI.ComboBox_Width.Items.Count - 1) AndAlso
CDec(GUI.ComboBox_Width.Text) <= GUI.ComboBox_Width.Items(0) Then CInt(GUI.ComboBox_Width.Text) <= GUI.ComboBox_Width.Items(0) Then
gratingMaxW = CDec(GUI.ComboBox_Width.Text) gratingMaxW = CInt(GUI.ComboBox_Width.Text)
GUI_Drawing_Panel.Update_GratingPoints() GUI_Drawing_Panel.Update_GratingPoints()
End If End If
End If End If
@ -347,8 +347,8 @@
Public Shared Sub LengthChanged(sender As Object, e As EventArgs) Public Shared Sub LengthChanged(sender As Object, e As EventArgs)
If GUI.TextBox_Length.Text <> "" Then If GUI.TextBox_Length.Text <> "" Then
If CDec(GUI.TextBox_Length.Text) >= 200 AndAlso CDec(GUI.TextBox_Length.Text) <= 6000 Then If CInt(GUI.TextBox_Length.Text) >= 200 AndAlso CInt(GUI.TextBox_Length.Text) <= 6000 Then
gratingMaxL = CDec(GUI.TextBox_Length.Text) gratingMaxL = CInt(GUI.TextBox_Length.Text)
GUI_Drawing_Panel.Update_GratingPoints() GUI_Drawing_Panel.Update_GratingPoints()
Else Else
'Message: Out of boundary 'Message: Out of boundary

View File

@ -1,7 +1,7 @@
Imports XCCLibrary Imports XCCLibrary
Imports SldWorks Imports SldWorks
Public Class SW_Drawing_Gratings Public Class SW_Drawing_Gratings
Private Shared sideCounter As Integer() = {0, 0, 0, 0} Private Shared sideCounter As Integer()
Public Shared Sub CreateDrawing() Public Shared Sub CreateDrawing()
Dim pointTable As New DataTable Dim pointTable As New DataTable
pointTable = GUI_Gratings_Data.Create_PointTable() pointTable = GUI_Gratings_Data.Create_PointTable()
@ -83,6 +83,8 @@ Public Class SW_Drawing_Gratings
End Sub End Sub
Private Shared Sub Create_Drawing(iModel As SldWorks.IModelDoc2) Private Shared Sub Create_Drawing(iModel As SldWorks.IModelDoc2)
sideCounter = {0, 0, 0, 0}
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)
@ -99,12 +101,43 @@ Public Class SW_Drawing_Gratings
Dim swSheet As Sheet Dim swSheet As Sheet
swSheet = iDrawing.GetCurrentSheet() swSheet = iDrawing.GetCurrentSheet()
swSheet.SetProperties2(12, 12, 1, 1, False, swSheetWidth, swSheetHeight, True) swSheet.SetProperties2(12, 12, 1, 1, False, swSheetWidth, swSheetHeight, True)
swSheet.SetTemplateName("C:\ProgramData\SolidWorks\SOLIDWORKS 2020\lang\english\sheetformat\a3 - iso.slddrt") swSheet.SetTemplateName(GUI.filepath & "\X2021\Weland ritningsmallar\A3 Part.slddrt")
swSheet.ReloadTemplate(True) swSheet.ReloadTemplate(True)
Dim myView As View Dim myView As View
myView = iDrawing.CreateDrawViewFromModelView3(GUI.filepath & "\Temp\TESTPART1.SLDPRT", "*Front", swSheetWidth / 2, swSheetHeight / 2, 0) myView = iDrawing.CreateDrawViewFromModelView3(GUI.filepath & "\Temp\TESTPART1.SLDPRT", "*Front", swSheetWidth / 2, swSheetHeight / 2, 0)
Dim viewScale = myView.ScaleDecimal() 'Dim viewScale = myView.ScaleDecimal()
Dim viewScale As Double
Dim lengthForDrawing As Integer = GUI_Gratings_Data.gratingMaxL
Dim widthForDrawing As Integer = GUI_Gratings_Data.gratingMaxW
If lengthForDrawing < widthForDrawing * 3 Then
'W styr
If widthForDrawing < 100 Then
viewScale = 1
ElseIf widthForDrawing < 200 Then
viewScale = 0.5
ElseIf widthForDrawing < 500 Then
viewScale = 0.2
Else
viewScale = 0.1
End If
Else
If lengthForDrawing < 300 Then
viewScale = 1
ElseIf lengthForDrawing < 600 Then
viewScale = 0.5
ElseIf lengthForDrawing < 1500 Then
viewScale = 0.2
ElseIf lengthForDrawing < 3000 Then
viewScale = 0.1
Else
viewScale = 0.05
End If
End If
myView.ScaleDecimal() = viewScale
Dim swExtensions As SldWorks.ModelDocExtension Dim swExtensions As SldWorks.ModelDocExtension
swExtensions = iDrawing.Extension swExtensions = iDrawing.Extension
@ -125,7 +158,9 @@ Public Class SW_Drawing_Gratings
Add_Dimensions(GUI_Functions.pointsMeasurements("Lmes"), CompName, myView, iDrawing, swExtensions, OutLine, viewScale, X_Mid, Y_Mid) Add_Dimensions(GUI_Functions.pointsMeasurements("Lmes"), CompName, myView, iDrawing, swExtensions, OutLine, viewScale, X_Mid, Y_Mid)
Add_Dimensions(GUI_Functions.pointsMeasurements("Wmes"), CompName, myView, iDrawing, swExtensions, OutLine, viewScale, X_Mid, Y_Mid) Add_Dimensions(GUI_Functions.pointsMeasurements("Wmes"), CompName, myView, iDrawing, swExtensions, OutLine, viewScale, X_Mid, Y_Mid)
Dim myView2 As View Dim myView2 As View
myView2 = iDrawing.CreateDrawViewFromModelView3(GUI.filepath & "\Temp\TESTPART1.SLDPRT", "*Bottom", swSheetWidth / 2, OutLine(3) + 0.03, 0) myView2 = iDrawing.CreateDrawViewFromModelView3(GUI.filepath & "\Temp\TESTPART1.SLDPRT", "*Bottom", swSheetWidth / 2, OutLine(3) + sideCounter(0) * 0.01 + 0.03, 0)
myView2.ScaleDecimal() = viewScale
Dim OutLine2 = myView2.GetOutline Dim OutLine2 = myView2.GetOutline
Dim point1Name As String = "Front Plane@" & CompName & "@" & myView2.GetName2 Dim point1Name As String = "Front Plane@" & CompName & "@" & myView2.GetName2
@ -135,7 +170,7 @@ Public Class SW_Drawing_Gratings
Dim measurement As IDisplayDimension Dim measurement As IDisplayDimension
swExtensions.SelectByID2(point1Name, "PLANE", 0, 0, 0, True, 0, Nothing, 0) swExtensions.SelectByID2(point1Name, "PLANE", 0, 0, 0, True, 0, Nothing, 0)
swExtensions.SelectByID2(point2Name, "PLANE", 0, 0, 0, True, 0, Nothing, 0) swExtensions.SelectByID2(point2Name, "PLANE", 0, 0, 0, True, 0, Nothing, 0)
measurement = iDrawing.AddVerticalDimension2(OutLine2(2), OutLine2(1), 0) measurement = iDrawing.AddVerticalDimension2(OutLine2(2) + 0.005, OutLine2(1), 0)
@ -176,9 +211,9 @@ Public Class SW_Drawing_Gratings
End If End If
If points(2) = 1 Then If points(2) = 1 Then
measurement = iDrawing.AddHorizontalDimension2(X_Mid + xPos * viewScale, OutLine(3) + mesOffset * sideCounter(0), 0) measurement = iDrawing.AddHorizontalDimension2(X_Mid + xPos * viewScale, OutLine(3) + 0.005 + mesOffset * sideCounter(0), 0)
Else Else
measurement = iDrawing.AddHorizontalDimension2(X_Mid + xPos * viewScale, OutLine(1) - mesOffset * sideCounter(2), 0) measurement = iDrawing.AddHorizontalDimension2(X_Mid + xPos * viewScale, OutLine(1) - 0.005 - mesOffset * sideCounter(2), 0)
End If End If
Else Else
Dim point1 As Decimal = GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(points(0) - 1))(3) Dim point1 As Decimal = GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(points(0) - 1))(3)
@ -192,14 +227,15 @@ Public Class SW_Drawing_Gratings
End If End If
If points(2) = 2 Then If points(2) = 2 Then
measurement = iDrawing.AddVerticalDimension2(OutLine(2) + mesOffset * sideCounter(1), Y_Mid + yPos * viewScale, 0) measurement = iDrawing.AddVerticalDimension2(OutLine(2) + 0.005 + mesOffset * sideCounter(1), Y_Mid + yPos * viewScale, 0)
Else Else
measurement = iDrawing.AddVerticalDimension2(OutLine(0) - mesOffset * sideCounter(3), Y_Mid + yPos * viewScale, 0) measurement = iDrawing.AddVerticalDimension2(OutLine(0) - 0.005 - mesOffset * sideCounter(3), Y_Mid + yPos * viewScale, 0)
End If End If
End If End If
sideCounter(points(2) - 1) = sideCounter(points(2) - 1) + 1 sideCounter(points(2) - 1) = sideCounter(points(2) - 1) + 1
iDrawing.ClearSelection2(True) iDrawing.ClearSelection2(True)
'measurement.SetWitnessLineGap(1, True, 0.001) ' For break dimension line
measurement.SetUnits2(False, 0, 1, 0, True, 12) measurement.SetUnits2(False, 0, 1, 0, True, 12)
measurement.CenterText = True measurement.CenterText = True
measurement.SetPrecision3(0, 0, 0, 0) measurement.SetPrecision3(0, 0, 0, 0)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.