AnsweredAssumed Answered

How to create line in view

Question asked by Yong Ning on Dec 22, 2016
Latest reply on Dec 25, 2016 by Yong Ning

Follow code,The location of the Drawing line is wrong





Coordinate , How to create point in view.







Function CreateCenterLine(SwModel As ModelDoc2, SwDispDim As DisplayDimension)

   Dim SwAnn As Annotation, Ss

       Set SwAnn = SwDispDim.GetAnnotation

       Ss = SwAnn.GetAttachedEntities

   Dim SwPt As SketchPoint, SwSketchSeg As SketchSegment

   Dim SwSketchLine As SketchLine

   Dim X(1), Y(1)

       For ii = 0 To 1

          Set SwPt = Ss(ii)

          With SwPt

             X(ii) = .X

             Y(ii) = .Y

          End With

       Next ii

       Set SwSketchLine = SwModel.CreateLine2(X(0), Y(0), 0, X(1), Y(1), 0)

       Set SwSketchSeg = SwSketchLine

       SwSketchSeg.ConstructionGeometry = True

       SwSketchSeg.Layer = "中心线"






End Function





Private Sub ll()

   Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

       Set SwApp = Application.SldWorks

       Set SwModel = SwApp.ActiveDoc

   Dim SwDraw As DrawingDoc

       Set SwDraw = SwModel

   Dim SwView As View

       Set SwView = SwDraw.GetFirstView '

       Set SwView = SwView.GetNextView

       SwDraw.ActivateView SwView.Name

   Dim SwSelMgr As SelectionMgr

       Set SwSelMgr = SwModel.SelectionManager

   Dim SwDispDim As DisplayDimension, SwDim As Dimension, SwAnn As Annotation

       Set SwDispDim = SwSelMgr.GetSelectedObject5(1)

       CreateCenterLine SwDraw, SwDispDim


End Sub