I nedd to get coordinates (x,y,<z>) of points / vertex selected on drawing view.
Does enyone can help me?
Here the sample of how convert vertex's coordiinates into a Drawing's ones
...Dim swMathUtils As SldWorks.MathUtilityDim swXform As SldWorks.MathTransformDim swMathPt As SldWorks.MathPoint
Set swMathUtils = swApp.GetMathUtility
Set swXform = swView.ModelToViewTransform Set swMathPt = swMathUtils.CreatePoint(swVertex.GetPoint())Set swMathPt = swMathPt.MultiplyTransform(swXform) 'Now the coordinates converted to drawing spaceDebug.Print swMathPt.ArrayData(0) & "; " & swMathPt.ArrayData(1)...
Visit us at SolidWorks World in the Partner Pavilion - Booth 735
GetSelectionPoint2 Method (ISelectionMgr) should get the selected point in model space coordinates from the currently selected object.
The coide below will give you x,y & z on last picked point. Click anywhere in the drawing and then run the macro.
Sub main()Dim swApp As SldWorks.SldWorksDim swModel As ObjectDim PickPt As VariantSet swApp = Application.SldWorksSet swModel = swApp.ActiveDocIf swModel Is Nothing Then MsgBox "No document loaded!", vbCritical: End If swModel.GetType = 3 Then PickPt = swModel.GetInsertionPoint Debug.Print PickPt(0) Debug.Print PickPt(1) Debug.Print PickPt(2) Else: MsgBox "Current File in not a drawing", vbCritical: End End If End Sub
I need to find coordinates of vertex not pick point. Pickpoint could be different from vertex position a specialy when I use selection filter.
I think that I can use measure tool to get coordinates, but there is other problem. I had preselected some points but to measure position I need to have selected only one point/ vertex. How can I remember selection and then loop thru it by selecting only one point per iteration to measure it?
In order to convert the coordinates of entities to the Drawing space you should use the view's transforms (View::ModelToViewTransform). Check the "Dimension Edge in Drawing (VB6)" example in API Help.
I can retriew entity from selected verticies but I'm unable to convert them in to SolidWorks points to get swPoint.ArrayData(0)
Can you help me with that?
Thanks a lot.
Now I'm able to retrieve coordinates from selected points.
Retrieving data ...