1 Reply Latest reply on Dec 27, 2016 8:23 AM by Ivana Kolin

    GetOutline → bounding box for a view → error.

    Yong Ning

      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

        • Re: GetOutline → bounding box for a view → error.
          Ivana Kolin
          Private Sub d20161223()
              Dim Var                                       As Variant
              Dim vPos                                      As Variant
              Dim tmp                                       As Variant
              Dim oScale                                    As Double
              Dim SwApp                                     As SldWorks.SldWorks
              Dim SwModel                                   As ModelDoc2
              Dim swSelMgr                                  As SelectionMgr
              Dim SwDraw                                    As DrawingDoc
              Dim SwView                                    As View
              Dim ii                                        As Integer
              Set SwApp = Application.SldWorks
              Set SwModel = SwApp.ActiveDoc
              Set swSelMgr = SwModel.SelectionManager
              Set SwDraw = SwModel
              Set SwView = swSelMgr.GetSelectedObject5(1)
              SwDraw.ActivateView SwView.Name
              oScale = SwView.ScaleDecimal
              With SwDraw
                  Var = SwView.GetOutline
                  vPos = SwView.Position
                  Var(2) = vPos(0) - Var(2)
                  Var(3) = vPos(1) - Var(3)
                  Var(0) = vPos(0) - Var(0)
                  Var(1) = vPos(1) - Var(1)
                  For ii = 0 To UBound(Var)
                      Var(ii) = Var(ii) / oScale
                  Next ii
                  tmp = .SketchRectangle(Var(0), Var(1), 0, Var(2), Var(3), 0, False)
              End With
          Stop
          End Sub