Hi guys,
I'm trying to change the shading of a single view in my macro. The macro creates a view then a project view form "Drawing View1". I'm then wanting to change the shading and scale of the newly created view two. I have been playing around and currently I'm changing the shading and scale and all views not just view one. Can some correct me where I'm going wrong. this is a snippet of my code;
Dim vScaleRatio As Variant
boolstatus = swModel.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 0.13842553485699, 0.137862387566601, 0, False, 0, Nothing, 0)
Set myView = swModel.CreateUnfoldedViewAt3(0.180250386904157, 0.13971698113208, 0, True)
swModel.ClearSelection2 True
boolstatus = swModel.Extension.SelectByID2("Drawing View2", "DRAWINGVIEW", 0.13842553485699, 0.187862387566601, 0, False, 0, Nothing, 0)
vScaleRatio = swView.ScaleRatio
swView.ScaleDecimal = swView.ScaleDecimal * 0.7
vScaleRatio = swView.ScaleRatio
boolstatus = swModel.EditRebuild3()
swView.SetDisplayMode3 False, swSHADED, True, True
Regards
Mat
We need to create New object for Drawing view2 .. Cheers
Try this...
Option Explicit
Dim swApp As Object
Dim Part As ModelDoc2
Dim swModel As DrawingDoc
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim myView As View
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set swModel = Part
boolstatus = Part.ActivateView("Drawing View1")
boolstatus = Part.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 0.51545, 0.59543, 0, False, 0, Nothing, 0)
Set myView = swModel.CreateUnfoldedViewAt3(0.180250386904157, 0.13971698113208, 0, True)
swModel.ClearSelection2 True
Dim swview As View
boolstatus = swModel.Extension.SelectByID2("Drawing View2", "DRAWINGVIEW", 0.13842553485699, 0.187862387566601, 0, False, 0, Nothing, 0)
Set swview = Part.SelectionManager.GetSelectedObject6(1, -1)
Dim vScaleRatio As Variant
vScaleRatio = swview.ScaleRatio
swview.ScaleDecimal = swview.ScaleDecimal * 0.7
vScaleRatio = swview.ScaleRatio
swview.SetDisplayMode3 False, swSHADED, True, True
boolstatus = swModel.EditRebuild3()
End Sub