Creates a coordinate system feature using the specified numerical values for position and orientation with respect to the global coordinate system.
'VBA
'=============================================
'Preconditions:
'1. Open a new part.
'2. Open the Immediate window.
'Postconditions:
'1. Creates a new coordinate system at the specified position and angle relative to the global coordinate system.
'2. Select Coordinate System1 in the FeatureManager design tree.
'3. Inspect the Immediate window and graphics area.
'=============================================
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeatMgr As FeatureManager
Dim swCoordFeat As SldWorks.Feature
Dim posVal, angVal As Double
Dim pos, ang As Double
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swFeatMgr = swModel.FeatureManager
pos = 200
posVal = pos / 1000 ' Position in meters
' 1 radian = 180º/p = 57.295779513º or approximately 57.3º
ang = 60
angVal = ang / 57.295779513 ' Angle in radians
Debug.Print "Position(mm) : [" & pos & ", " & pos & ", " & pos & "] Angle(deg) : [" & ang & ", " & ang & ", " & ang & "] "
Set swCoordFeat = swFeatMgr.CreateCoordinateSystemUsingNumericalValues(True, posVal, posVal, posVal, True, angVal, angVal, angVal)
Debug.Print "Name of the coordinate system feature : " & swCoordFeat.Name
End Sub