AnsweredAssumed Answered

GetOutline → bounding box for a view → error.

Question asked by Yong Ning on Dec 22, 2016
Latest reply on Dec 27, 2016 by Ivana Kolin

This method returns the bounding box for a view (sheet or drawing view) in meters on the drawing page

 

View.GetOutline () → Follow code , Drawing bounding box is error.

.

 

 

 

 

OutLine1.jpg

 

 

OutLine2.jpg

 

 

Private Sub del20161223()

   Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

       Set SwApp = Application.SldWorks

       Set SwModel = SwApp.ActiveDoc

   Dim swSelMgr As SelectionMgr, Ss

       Set swSelMgr = SwModel.SelectionManager

   Dim SwDraw As DrawingDoc, SwView As View

       Set SwDraw = SwModel

       Set SwView = swSelMgr.GetSelectedObject5(1)

       Debug.Print SwView.Name

       Ss = SwView.GetOutline

       SwDraw.ActivateView SwView.Name

        'tmp = SwDraw.SketchRectangle(-Ss(2), -Ss(3), 0, Ss(2), Ss(3), 0, 1)

        tmp = SwDraw.SketchRectangle(Ss(0), Ss(1), 0, Ss(2), Ss(3), 0, 1)

       Stop

     

End Sub

Private Sub d20161223()

   Dim Var, vPos, tmp, oScale, Vpts

 

   ''

   Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

       Set SwApp = Application.SldWorks

       Set SwModel = SwApp.ActiveDoc

   Dim swSelMgr As SelectionMgr, Ss

       Set swSelMgr = SwModel.SelectionManager

   Dim SwDraw As DrawingDoc, SwView As View

       Set SwDraw = SwModel

       ''''

       Set SwView = swSelMgr.GetSelectedObject5(1)

       SwDraw.ActivateView SwView.Name

       oScale = 1 ' / SwView.ScaleDecimal

       ''

       With SwDraw

             Var = SwView.GetOutline

             vPos = SwView.Position

             Vpts = SwView.GetXform

             For ii = 0 To UBound(Var)

                 Var(ii) = oScale * Var(ii)

                 If ii < 2 Then

                    'vPos(ii) = oScale * vPos(ii)

                    vPos(ii) = vPos(ii)

                 End If

             Next ii

             ''

             tmp = .SketchRectangle(-Var(2), -Var(3), 0, Var(2), Var(3), 0, 1)

             tmp = .SketchRectangle(vPos(0), vPos(1), 0, Var(2), Var(3), 0, 1)

       End With

     

       Stop

     

End Sub

Attachments

Outcomes