MultiplyTransform + ModelToViewTransform,
result is error .
''
Private Sub ll3()
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
Dim SwViewXForm
Set SwViewXForm = SwView.ModelToViewTransform
Dim swSelMgr As SelectionMgr
Set swSelMgr = swModel.SelectionManager
Dim swDispDim As DisplayDimension, SwDim As Dimension
Set swDispDim = swSelMgr.GetSelectedObject5(1)
Set SwDim = swDispDim.GetDimension
Dim SwAnn As Annotation
Set SwAnn = swDispDim.GetAnnotation
Ss = SwDim.ReferencePoints
Dim SwPt As SketchPoint, Pp
Dim SwPt1 As MathPoint, SwPt2 As MathPoint
Pp = SwAnn.GetPosition
Set SwPt1 = Ss(1)
Set SwPt1 = SwPt1.MultiplyTransform(SwViewXForm)
Set SwPt2 = Ss(2)
Set SwPt2 = SwPt2.MultiplyTransform(SwViewXForm)
Dim Xx, Yy, Xx1, Yy1, Xx2, Yy2
''
Xx = Pp(0)
Yy = Pp(1)
''
Xx1 = SwPt1.ArrayData(0)
Yy1 = SwPt1.ArrayData(1)
''
Xx2 = SwPt2.ArrayData(0)
Yy2 = SwPt2.ArrayData(1)
Debug.Print Xx * 1000, Yy * 1000
Debug.Print Xx1 * 1000, Yy1 * 1000
Debug.Print Xx2 * 1000, Yy2 * 1000
swModel.CreateLine2 Xx1, Yy1, 0, Xx2, Yy2, 0
swModel.CreateLine2 Xx, Yy, 0, Xx2, Yy2, 0
swModel.CreateLine2 Xx1, Yy1, 0, Xx, Yy, 0
Stop
End Sub
SolidworksApi macros
I think the problem is that CreateLine2 is using the drawing coordinates and you are giving it the view coordinates (or vice versa).
When I attempted this a while back, I ended up just building a transform from view sketch to drawing sketch coordinates because I couldn't figure out which API-provided transforms to use.
Thanks your tips.
Question is using the drawing coordinates and you are giving it the view coordinates?