1 Reply Latest reply on Dec 10, 2014 8:46 PM by Subhra Maiti

    Section line coordinate in drawing view

    Subhra Maiti

      I want to get the section line starting position in drawing doc.

      I am using

      --------------------------------------------------------------------------------------------------------------------------------------

      Set swApp = Application.SldWorks

      Set Part = swApp.ActiveDoc

      boolstatus = Part.Extension.SelectByID2("Section Line2", "SECTIONLINE", 0, 0, 0, False, 0, Nothing, 0)

      Set swFeat = Part.SelectionManager.GetSelectedObject6(1, 0)

      Set swSectionLine = swFeat.GetSpecificFeature2

       

      v2 = swSectionLine.GetLineInfo

       

      Dim v3(0 To 2) As Double

      v3(0) = v2(0)

      v3(1) = v2(1)

      v3(2) = v2(3)

       

      v4 = v3

       

      Dim swMathUtils As SldWorks.MathUtility

      Dim swXform As SldWorks.MathTransform

      Dim swMathPt As SldWorks.MathPoint

      Set swMathUtils = swApp.GetMathUtility

      Set swXform = swView.ModelToViewTransform

      Set swMathPt = swMathUtils.CreatePoint(v4)

      Set swMathPt = swMathPt.MultiplyTransform(swXform)

       

      MsgBox (swMathPt.ArrayData(0) * 1000 & vbCrLf & swMathPt.ArrayData(1) * 1000 & vbCrLf & swMathPt.ArrayData(2) * 1000)

       

      ---------------------------------------------------------------------------------------------------------------------------------------------

       

      Its gives me wrong result. What is wrong? Please help

        • Re: Section line coordinate in drawing view
          Subhra Maiti

          Finally got a solution. The things are happening 1) Section Line is in the drawing view coordinate

                                                                                       2) Y axis of drawing view coordinate is in the X direction of Drawing Sheet coordinate

           

           

          -------------------------------------------------------------------------------------------------------------------------------------------------------------------------

          Set swApp = Application.SldWorks

          Set Part = swApp.ActiveDoc

          boolstatus = Part.Extension.SelectByID2("Section Line2", "SECTIONLINE", 0, 0, 0, False, 0, Nothing, 0)

          Set swFeat = Part.SelectionManager.GetSelectedObject6(1, 0)

          Set swSectionLine = swFeat.GetSpecificFeature2

           

          boolstatus = Part.Extension.SelectByID2("Drawing View9", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)

          Set swView = Part.SelectionManager.GetSelectedObject6(1, -1)

           

          'Getting outline coordinate to set the section line

          v1 = swView.GetOutline

          v2 = swSectionLine.GetLineInfo

          v3 = swView.GetXform

           

          'Setting section line coordinate to drawing view outline

          v2(4) = (v3(0) - v1(0)) * (1 / v3(2))

          v2(1) = (v3(0) - v1(2)) * (1 / v3(2))

           

          boolstatus = swSectionLine.SetLineInfo(v2)

          boolstatus = Part.EditRebuild3

          ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

           

          It works great for me. Thank you.