Drawing View Exploded size

I am trying to center an exploded view on a drawing sheet through an API. However when i get the outline of the view it gives me the outline of the collapsed view, not the exploded view.

The drawing view is inserted and in the exploded state when i call swView.GetOutline

I am looking for some code like this?

swView.GetExplodedOutline

Thanks

SolidworksApi macros
Answers 6
JS
JS 2017-07-11 Best Answer
EB
EB 2017-07-11

I can make the drawing with the views without any problem. But i am trying to center my exploded view on the sheet. When i call getOutline it gives me the outline of the collapsed view not the exploded view.

AJ
AJ 2017-07-11

I had this problem before. Set the view at 0,0, get the size, explode the view then get the difference width and height difference and use that to center the view. The coordinate will be that of the view collapsed.

NP
NP 2017-07-11

Hi Eric,

Following codes works fine for me. I can get outline of both exploded and collapsed view. Run the macro two times. First with the collapsed view and then with the exploded view. The drawing view must be selected before running the macro. IView.Postion always returns position of the collapsed view as ​ mentioned.

<p>Option Explicit</p><p></p><p></p><p>Dim swApp       As SldWorks.SldWorks</p><p>Dim swModel     As SldWorks.ModelDoc2</p><p>Dim swDraw      As SldWorks.DrawingDoc</p><p>Dim swView      As SldWorks.View</p><p>Dim vOutline    As Variant</p><p>Dim vPos        As Variant</p><p>Sub main()</p><p></p><p></p><p>    Set swApp = Application.SldWorks</p><p>    Set swModel = swApp.ActiveDoc</p><p>    Set swDraw = swModel</p><p>    </p><p>    Set swView = swDraw.ActiveDrawingView</p><p>    </p><p>    vPos = swView.Position</p><p>    vOutline = swView.GetOutline</p><p>    </p><p>    Debug.Print swView.Name</p><p>    Debug.Print "Position:"</p><p>    Debug.Print vPos(0) * 1000</p><p>    Debug.Print vPos(1) * 1000</p><p>    </p><p>    Debug.Print "Outline:"</p><p>    Debug.Print vOutline(0) * 1000</p><p>    Debug.Print vOutline(1) * 1000</p><p>    Debug.Print vOutline(2) * 1000</p><p>    Debug.Print vOutline(3) * 1000</p><p>    </p><p>End Sub</p>

Are you creating exploded view manually or through API?

Regards,

AJ
AJ 2017-07-11

There you go. Problem solved!

EB
EB 2017-07-12

Yes I got it figured out thanks everyone!