I'm trying to update a Solidworks VBA script to adjust properties of a view after it has already been placed and am unsure how to actually do this. In the GUI once I select the view I can edit these properties (e.g. display state, scale, dimension type) via the property manager and the drawing view tab. If I try to make a macro that I can then use as my baseline I only get my the selection of the drawing view from SelectByID2.
boolstatus = Part.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", x, y, z, False, 0, Nothing, 0)
Part.ClearSelection2 True
Is there a way to actually modify these properties once the drawing view has already been placed?
It's possible to change a DrawingView after it has been placed.
You can find documentation on the IView Interface Members
here
The code below doubles the selected view scale. The code is from here
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swSelMgr As SldWorks.SelectionMgr
Dim swView As SldWorks.View
Dim vScaleRatio As Variant
Dim bRet As Boolean
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swSelMgr = swModel.SelectionManager
Set swView = swSelMgr.GetSelectedObject6(1, -1)
vScaleRatio = swView.ScaleRatio
Debug.Print "File = " & swModel.GetPathName
Debug.Print " View = " & swView.Name
Debug.Print " Use sheet scale = " & CBool(swView.UseSheetScale)
Debug.Print " Original scale ratio = " & vScaleRatio(0) & ":" & vScaleRatio(1)
Debug.Print " Original decimal scale value = " & swView.ScaleDecimal
' Increase scale values
' Changing scale sets IView::UseSheetScale to false
vScaleRatio = swView.ScaleRatio
swView.ScaleDecimal = swView.ScaleDecimal * 2#
vScaleRatio = swView.ScaleRatio
Debug.Print ""
Debug.Print " Use sheet scale = " & CBool(swView.UseSheetScale)
Debug.Print " New scale ratio = " & vScaleRatio(0) & ":" & vScaleRatio(1)
Debug.Print " New decimal scale value = " & swView.ScaleDecimal
' Rebuild to see the scaled drawing view
bRet = swModel.EditRebuild3: Debug.Assert bRet
End Sub
Here you can find documentation on the IView Interface
and more links to examples.