AnsweredAssumed Answered

How to create line in view with API

Question asked by Yong Ning on Oct 12, 2016
Latest reply on Oct 13, 2016 by Peter Brinkhuis

Follow code  create line have error.

''

 

 

Private Sub ll5()

    Dim swApp As SldWorks.SldWorks, swModel As ModelDoc2

         Set swApp = Application.SldWorks

         Set swModel = swApp.ActiveDoc

    Dim swDraw As DrawingDoc

         Set swDraw = swModel

    Dim SwSheet As Sheet

         Set SwSheet = swDraw.GetCurrentSheet

    Dim SwSelMgr As SelectionMgr

         Set SwSelMgr = swModel.SelectionManager

    Dim SwView As View, SwView1 As View

         Set SwView = SwSelMgr.GetSelectedObject5(1)

       

    Dim Var, vPos, oScale

        oScale = SwSheet.GetProperties(3)

      

        Var = SwView.GetOutline

        vPos = SwView.Position

    Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double

        x2 = 0 'Var(0) '+ (Var(2) - Var(0)) / 2

        y2 = Abs(vPos(1) - Var(3)) * oScale

        x1 = x2

        y1 = -y2

        swDraw.CreateLine2 x1, y1, 0, x2, y2, 0 ', True

        'Set swView = swDraw.CreateSectionViewAt4(0.2, y2, 0, "A", 2, ExcludedComponents)

        Set SwView1 = swDraw.CreateSectionViewAt4(0.15, 0, 0, "A", 16, ExcludedComponents)

        Stop

End Sub

 

 

1.jpg

 

 

2.jpg

Attachments

Outcomes