I have never been able to select the coordinates system in SOLIDWORKS. It's a design flaw of the API. I might be wrong. The thing is I don't really use the IMeasure interface because the results it gives are so ultraprecise (10^(-10m) precision) - which is something you don't really need especially if you're calculating perpendicularity between edges (for example) with a tolerances values in the 10^-3mm range - I have yet to see an application that plays at the angstrom level in SOLIDWORKS.
If you're selecting a plane (IRefPlane), then you're having access to the RefPlane::CornerPoints property. This gives you four IMathPoint that belongs to the plane.
Next, traverse all the features to get the coordinate system. Use Feature::GetDefinition to get the data object for the coordinate system feature (ICoordinateSystemFeatureData).
This object has a property called OriginEntity. It will return Entity object. You need to figure what entity type this object is in order to cast into the right type and then get the coordinate or the origin.
What is left to you is some simple math.
Btw, this is blazingly faster than using Measure.
thank you everybody,
i notice that i'm not be done clear with my question
i'm in a context of assembly , i'm not in a part , and i need recursively take a measure beetween coordinate system inside a part
and planes inside other parts
A coordinate system has a transformation matrix that you can use.
hy Amen you say truu
but if u have a component with a secondary coordinate system named for example "pippo" the transform Matrix
Public Enum swUserPreferenceStringValue_e
swFileSaveAsCoordinateSystem = 16
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDocExt As SldWorks.ModelDocExtension
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.Feature
Dim swXform As SldWorks.MathTransform
Dim sAxisName As String
Dim bRet As Boolean
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDocExt = swModel.Extension
Set swSelMgr = swModel.SelectionManager
Set swFeat = swSelMgr.GetSelectedObject5(1)
Debug.Print "File = " & swModel.GetPathName
Debug.Print " Current coordinate system = " & swModel.GetUserPreferenceStringValue(swFileSaveAsCoordinateSystem)
sAxisName = swFeat.Name
Set swXform = swDocExt.GetCoordinateSystemTransformByName(sAxisName)
Debug.Print " " & sAxisName
Debug.Print " Origin = (" & -1# * swXform.ArrayData(9) * 1000# & ", " & -1# * swXform.ArrayData(10) * 1000# & ", " & -1# * swXform.ArrayData(11) * 1000# & ") mm"
Debug.Print " Rotational sub-matrix 1 = (" & swXform.ArrayData(0) & ", " & swXform.ArrayData(1) & ", " & swXform.ArrayData(2) & ")"
Debug.Print " Rotational sub-matrix 2 = (" & swXform.ArrayData(3) & ", " & swXform.ArrayData(4) & ", " & swXform.ArrayData(5) & ")"
Debug.Print " Rotational sub-matrix 3 = (" & swXform.ArrayData(6) & ", " & swXform.ArrayData(7) & ", " & swXform.ArrayData(8) & ")"
Debug.Print " Translation vector = (" & swXform.ArrayData(9) * 1000# & ", " & swXform.ArrayData(10) * 1000# & ", " & swXform.ArrayData(11) * 1000# & ") mm"
Debug.Print " Scale = " & swXform.ArrayData(12)
this method doesn't work
how can i transform the coordinate system that is inside a component at the level of assembly ??
Why are you not using the MathUtility interface?
Hy Amen , i need to verify the orientation of the secondary Coordinate system of the component in the assembly space , in order to verify if ,,,,,for example ....the z axis of the secondary Cs is concord or in opposite direction rispect the global Cs of the assembly.do you think is it the right method ??
I'm not sure I fully understand you Luigi. You can still apply the transform matrix on the (0,0,1) zee vector to get its orientation with the regards to the assembly's coordinate system? Actually, I think you can get the entity that make the zee axis for the coordinate system of the component, then you can transform it to the assembly to see its orientation.