Dimension drawing test

This commit is contained in:
Mans 2021-02-02 14:53:36 +01:00
parent 5fc9f820a0
commit d68c64aaaa
2 changed files with 39 additions and 5 deletions

View File

@ -310,6 +310,9 @@ Public Class GUI
' --- When angle button is pressed ---
Private Sub AngleButton_Click(sender As Object, e As EventArgs) Handles AngleButton.Click
Me.Controls("AngleButton").Enabled = False
Me.Controls("Button_Square").Enabled = False
Dim buttonX As Integer = Me.Controls("AngleButton").Location.X
Dim buttonY As Integer = Me.Controls("AngleButton").Location.Y
@ -326,6 +329,9 @@ Public Class GUI
' --- When square button is pressed ---
Private Sub Button_Square_Click(sender As Object, e As EventArgs) Handles Button_Square.Click
Me.Controls("AngleButton").Enabled = False
Me.Controls("Button_Square").Enabled = False
Dim buttonX As Integer = Me.Controls("Button_Square").Location.X
Dim buttonY As Integer = Me.Controls("Button_Square").Location.Y
@ -490,6 +496,9 @@ Public Class GUI
Me.Controls.RemoveByKey("X_Label")
Me.Controls.RemoveByKey("Y_Label")
Me.Controls("AngleButton").Enabled = True
Me.Controls("Button_Square").Enabled = True
End Sub
' --- Settings button clicked ---
@ -503,13 +512,13 @@ Public Class GUI
exportTable = Create_ExportTable()
Program.Build_Grating(exportTable)
'Program.Build_Grating(exportTable)
'Test för att SW API
Dim pointTable As New DataTable
pointTable = Create_PointTable()
Program.Export_SW(pointTable)
Program.Export_SW(pointTable, 0.025) 'Make variable ref to Height
Program.Create_Drawing()
End Sub

View File

@ -39,7 +39,7 @@ Public Class Program
groupClass.InstantiateGroup(designName, grNr, "START")
End Sub
Public Shared Sub Export_SW(pointTable As DataTable)
Public Shared Sub Export_SW(pointTable As DataTable, gratingHeight As Decimal)
Dim swApp As SldWorks.SldWorks
swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks)
Dim Model As ModelDoc2
@ -98,16 +98,19 @@ Public Class Program
swFeatureMgr = Model.FeatureManager
Dim swFeature As Feature
swFeature = swFeatureMgr.FeatureExtrusion3(True, False, False, 0, 0, 0.001, 0, False, False, False, False, 0, 0, False, False, False, False, True, True, True, 0, 0, False)
swFeature = swFeatureMgr.FeatureExtrusion3(True, False, False, 0, 0, gratingHeight, 0, False, False, False, False, 0, 0, False, False, False, False, True, True, True, 0, 0, False)
Dim iPart As PartDoc
iPart = swApp.ActiveDoc
Dim newName As String
newName = "C:\Users\Anton\Documents\Exjobb\Temp" & "\TESTPART" & 1 & ".SLDPRT"
longstatus = iPart.SaveAs3(newName, 0, 0)
Create_Drawing(iPart)
End Sub
Public Shared Sub Create_Drawing()
Public Shared Sub Create_Drawing(iModel As SldWorks.IModelDoc2)
Dim swApp As SldWorks.SldWorks
swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks)
@ -130,6 +133,28 @@ Public Class Program
Dim myView As View
myView = iDrawing.CreateDrawViewFromModelView3("C:\Users\Anton\Documents\Exjobb\Temp\TESTPART1.SLDPRT", "*Front", swSheetWidth / 2, swSheetHeight / 2, 0)
Dim swExtensions = iModel.Extension
Dim RootComp = myView.RootDrawingComponent
Dim CompName = RootComp.Name
Dim dimension As SldWorks.IDisplayDimension
Dim OutLine = myView.GetOutline
Dim X_Mid = (OutLine(2) - OutLine(0)) / 2 + OutLine(0)
Dim Y_Mid = (OutLine(3) - OutLine(1)) / 2 + OutLine(1)
Dim point1Name As String = "Point1@Sketch1@TESTPART1.SLDPRT"
Dim point2Name As String = "Point2@Sketch1@TESTPART1.SLDPRT"
swExtensions.SelectByID2(point1Name, "POINT", 0, 0, 0, True, 0, Nothing, 0)
swExtensions.SelectByID2(point2Name, "POINT", 0, 0, 0, True, 0, Nothing, 0)
dimension = iDrawing.adddimension2(X_Mid, OutLine(1), 0)
iDrawing.ClearSelection2(True)
dimension.SetUnits2(False, 0, 1, 0, True, 12)
dimension.CenterText = True
dimension.SetPrecision3(0, 0, 0, 0)
Dim longstatus As Integer
Dim newName As String
newName = "C:\Users\Anton\Documents\Exjobb\Temp" & "\TESTDRAWING" & 1 & ".SLDDRW"