2 Replies Latest reply on Feb 9, 2017 3:35 AM by Yong Ning

    GetOutline→results different with  rotation or extension method

    Yong Ning

      Follow code GetOutline ,

      The results are different from the rotation method or the extension method

       

      With extendsion method , Correct result

       

      a1.jpga11.jpg

       

      With rotation method , Incorrect result

       

       

      a22.jpga2.jpg

       

       

       

       

       

       

       

       

      Function DimBreakOut1(SwDraw As DrawingDoc, SwView As View, DimDepth)

        

          Dim Var, vPos, tmp, oScale

          Dim SwDim As Dimension, Depth

          Dim DnDim As Dimension, ThkDim As Dimension

          Dim lDim As Dimension

          Dim SwModel As ModelDoc2

              Set SwModel = SwView.ReferencedDocument

              Debug.Print SwModel.GetPathName

              ''

          Dim Ww, Hh

              SwDraw.ActivateView SwView.Name

              SwDraw.ForceRebuild3 True

              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) / SwView.ScaleDecimal

              Next ii

              With SwDraw

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

                

              End With

      End Function

      Private Sub ll2()

          Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

               Set SwApp = Application.SldWorks

               Set SwModel = SwApp.ActiveDoc

          Dim SwSelMgr As SelectionMgr

               Set SwSelMgr = SwModel.SelectionManager

          Dim SwView As View

               Set SwView = SwSelMgr.GetSelectedObject5(1)

               Debug.Print SwView.Name

               DimBreakOut1 SwModel, SwView, ""

      End Sub

        • Re: GetOutline→results different with  rotation or extension method
          Raghvendra Bhargava

          Please check this out :

          Drawing View GetOutline

          Make sure in both the model Origin must be on the same position.

            • Re: GetOutline→results different with  rotation or extension method
              Yong Ning

              Thank your reply.

               

               

              ''

              Private Sub ll1()

                 Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                     Set SwApp = Application.SldWorks

                     Set SwModel = SwApp.ActiveDoc

                 Dim SwDraw As DrawingDoc

                     Set SwDraw = SwModel

                 Dim SwSelMgr As SelectionMgr

                     Set SwSelMgr = SwModel.SelectionManager

                 Dim SwSheet As Sheet

                     Set SwSheet = SwDraw.GetCurrentSheet

                 Dim SwView As View, Pt(2) As Double

                     Set SwView = SwSelMgr.GetSelectedObject5(1)

                 Dim vPos, Var, oScale, Ss

                     Ss = SwSheet.GetProperties

                     'oScale = Ss(3)

                     oScale = 1 / SwView.ScaleDecimal

                     SwView.Position = Pt

                    

                     ''

                     vPos = SwView.Position

                     Var = SwView.GetOutline

                     For ii = 0 To 3

                         Var(ii) = Var(ii) / SwView.ScaleDecimal

                     Next ii

                     ''

                    

                     For ii = 0 To 1

                         vPos(ii) = vPos(ii) / SwView.ScaleDecimal

                     Next ii

                

                 Dim SwSketchMgr As SketchManager

                 Dim SwPt1 As SketchPoint, SwPt2 As SketchPoint

                 Dim SwLine As SketchLine

                     Set SwSketchMgr = SwModel.SketchManager

                     With SwSketchMgr

                         'Set SwPt = .CreatePoint(vPos(0), vPos(1), 0)

                         Set SwPt1 = .CreatePoint(vPos(0) - Var(0), vPos(1) - Var(1), 0)

                         Debug.Print SwPt1.X, SwPt1.Y, SwPt1.Z

                         Stop

                         Set SwPt2 = .CreatePoint(vPos(0), vPos(1), 0)

                         With SwPt2

                              Debug.Print .X, .Y, .Z

                         End With

                         Set SwLine = .CreateLine(SwPt1.X, SwPt1.Y, 0, SwPt2.X, SwPt2.Y, 0)

                     End With

              End Sub