An dieser Stelle werde ich nach und nach die Videos zur automatischen Zeichnungserstellung verlinken. Da dieses Reihe deutlich größer ist als vorhergehende, habe ich das auf mehrere Streams verteilt. Schaut also immer mal wieder rein.
Und an dieser Stelle der Code der im Makro vorhanden ist.
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Set swApp = Application.SldWorks
Dim swModel As ModelDoc2
Set swModel = swApp.ActiveDoc
Dim swDrawing As DrawingDoc
Set swDrawing = swModel
Dim allViews As Variant
allViews = swDrawing.GetViews
Dim sheetViews As Variant
For Each sheetViews In allViews
Dim vView As Variant
For Each vView In sheetViews
Dim swView As view
Set swView = vView
Debug.Print swView.Name
If swView.Name = "Blatt1" Then
Dim vScale As Variant
vScale = swView.scaleRatio
vScale(0) = 1#
vScale(1) = 1#
swView.scaleRatio = vScale
swModel.EditRebuild3
End If
If swView.Name = "Zeichenansicht1" Then
Dim position As Variant
position = swView.position
position(0) = 110 / 1000
position(1) = 297 / 2 / 1000
swView.position = position
End If
Next
Next
swModel.EditRebuild3
End Sub
Und an dieser Stelle der Code der im Makro vorhanden ist.
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Set swApp = Application.SldWorks
Dim swModel As ModelDoc2
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then Exit Sub
Dim templatePath As String
'templatePath = "C:\ProgramData\SolidWorks\SOLIDWORKS 2023\templates\Zeichnung.drwdot"
templatePath = swApp.GetUserPreferenceStringValue(swUserPreferenceStringValue_e.swDefaultTemplateDrawing)
Dim paperSize As Long
paperSize = swDwgPaperSizes_e.swDwgPaperA4sizeVertical
Dim swDrawing As DrawingDoc
Set swDrawing = swApp.NewDocument(templatePath, paperSize, 0, 0)
Dim templateSize As Long
templateSize = swDwgTemplates_e.swDwgTemplateCustom
Dim templateSizePath As String
templateSizePath = "a4 - din.slddrt"
Dim bool As Boolean
bool = swDrawing.SetupSheet5("Blatt1", paperSize, templateSize, 1, 1, False, templateSizePath, 0, 0, "Standard", True)
bool = swDrawing.Create1stAngleViews2(swModel.GetTitle)
'bool = swDrawing.Create3rdAngleViews2(swModel.GetTitle)
End Sub