Allows access to a coordinate system element.
‘VBA
'---------------------------------------------------------------------
' Preconditions:
' 1. Open a part with a coordinate system.
' 2. Select any coordinate system element.
' 3. Open the Immediate window.
'
' Postconditions: Examine the Immediate window for the type of coordinate system element selected.
'---------------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.Feature
Dim swComponent As SldWorks.Component2
Dim swCoordSysFeat As SldWorks.CoordinateSystemFeatureData
Dim iSelType As Long
Dim isCoordSysElmSelected As Boolean
Dim swCordSysElement As SldWorks.CoordinateSystemElement
Dim boolstatus As Boolean
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'boolstatus = swModel.Extension.SelectByID2("Coordinate System1\X Axis", "COORDSYS", 0, 0, 0, False, 0, Nothing, 0)
'Select any coordinate system element
'Stop
Set swSelMgr = swModel.SelectionManager
Set swComponent = swSelMgr.GetSelectedObjectsComponent4(1, -1)
iSelType = swSelMgr.GetSelectedObjectType3(1, -1)
If iSelType = swSelCOORDSYS Then
isCoordSysElmSelected = swSelMgr.IsCoordSysElementSelected(1, -1)
If isCoordSysElmSelected = True Then
Set swCordSysElement = swSelMgr.GetSelectedCoordSysElement(1, -1)
Dim ElementType As Long
ElementType = swCordSysElement.GetElementType
Debug.Print "ElementType: " & ElementType
Set swFeat = swCordSysElement.GetCoordinateSystem
Set swCoordSysFeat = swFeat.GetDefinition
swCoordSysFeat.AccessSelections swModel, swComponent
'Stop
swCoordSysFeat.ReleaseSelectionAccess
End If
End If
End Sub