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
SolidworksApi macros
Changing single view Macro by - the shaded macro not sure who wrote that one
I can play with the macro to get it to-do it but it applies the changes to all views, the attached macros require me to select the view before running the macro. I'm wanting the macro to select the drawing view "drawing view2" I think its my method of selecting the view is incorrect.
The reason it changes all the views is the "Use Parent Scale" is checked
when I use this line with "False"
swView.SetDisplayMode3 False, swSHADED, True, True
it should use local setting and True to use the parent's setting, false to use its own local settings so should not apply to all the views
value = instance.SetDisplayMode3(UseParent, Mode, Facetted, Edges)
unless i'm missing something. I just don't think I have the correct method for setting swView to "Drawing View2" and I don't know what the correct method is.
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
Works a treat now!!
Thanks!