Hi,
I have filled out my first module and appear to have erred somewhere.
My code -
Sub Main()'Declare VariablesDim MyLine As LineElementDim MyCir As EllipseElementDim CenPt As Point3dDim LineSt As Point3dDim LineEn As Point3dDim RotMatrix As Matrix3d'Create Horizontal LineLineSt.X = -1LineEn.X = 1Set MyLine = Application.CreateLineElement2(Nothing, LineSt, LineEn)Application.ActiveModelReference.AddElement MyLine'Create Vertical LineLineSt.X = 0: LineSt.Y = 1LineEn.X = 0: LineEn.Y = -1Set MyLine = Application.CreateLineElement2(Nothing, LineSt, LineEn)Application.ActiveModelReference.AddElement MyLine'Create CirclesSet MyCir = Application.CreateEllipseElement2(Nothing, CenPt, 0.25, 0.25, RotMatrix)Application.ActiveModelReference.AddElement MyCirSet MyCir = Application.CreateEllipseElement2(Nothing, CenPt, 0.5, 0.5, RotMatrix)Application.ActiveModelReference.AddElement MyCirEnd Sub
'Front View'
How do I get the target to face up in the top view?
Cheers
Joshua Chung said: Dim RotMatrix As Matrix3d ... 'Create Circles Set MyCir = Application.CreateEllipseElement2(Nothing, CenPt, 0.25, 0.25, RotMatrix) Application.ActiveModelReference.AddElement MyCir
Dim RotMatrix As Matrix3d ... 'Create Circles Set MyCir = Application.CreateEllipseElement2(Nothing, CenPt, 0.25, 0.25, RotMatrix) Application.ActiveModelReference.AddElement MyCir
You're using variable RotMatrix without initialising it. Uninitialised variables in general are a bad thing.
VBA tries to protect us from ourselves by initialising native types (such as Integer and Double). However, Matrix3d is not a native type, and VBA does not know how to initialise it. The statement to initialise a Matrix3d is …
Dim rotation As Matrix3d rotation = Matrix3dIdentity
If you want to create a specific rotation, then one of the multitude of Matrix3dXxx methods may be useful. Start with Matrix3dFromAxisAndRotationAngle.
Regards, Jon Summers LA Solutions
Thanks Jon