'Target' module rotation error

Hi,

I have filled out my first module and appear to have erred somewhere.

My code -

Sub Main()
'Declare Variables
Dim MyLine As LineElement
Dim MyCir As EllipseElement
Dim CenPt As Point3d
Dim LineSt As Point3d
Dim LineEn As Point3d
Dim RotMatrix As Matrix3d
'Create Horizontal Line
LineSt.X = -1
LineEn.X = 1
Set MyLine = Application.CreateLineElement2(Nothing, LineSt, LineEn)
Application.ActiveModelReference.AddElement MyLine
'Create Vertical Line
LineSt.X = 0: LineSt.Y = 1
LineEn.X = 0: LineEn.Y = -1
Set MyLine = Application.CreateLineElement2(Nothing, LineSt, LineEn)
Application.ActiveModelReference.AddElement MyLine
'Create Circles
Set MyCir = Application.CreateEllipseElement2(Nothing, CenPt, 0.25, 0.25, RotMatrix)
Application.ActiveModelReference.AddElement MyCir
Set MyCir = Application.CreateEllipseElement2(Nothing, CenPt, 0.5, 0.5, RotMatrix)
Application.ActiveModelReference.AddElement MyCir
End Sub

'Front View'

 How do I get the target to face up in the top view?

 

Cheers

 

  • Matrix3d Initialisation

    Joshua Chung said:
    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

     
    Regards, Jon Summers
    LA Solutions