ZRotation Example

AEC Auto

ZRotation Example

Sub Example_ZRotation()
 
    
    ' This example will make a mass element and and anchor it to a line,
    ' and rotate it around the Z axis of the line 45 degrees
    
    Dim mass As AecMassElement
    Dim line As AcadLine
    Dim anchor As New AecAnchorEntToCurve
    Dim pt1(0 To 2) As Double
    Dim pt2(0 To 2) As Double
    
    pt2(0) = 1000: pt2(1) = 1000
    
    ' this makes a new mass element 120 x 120 x 120 at 0,0,0
    Set mass = ThisDrawing.ModelSpace.AddCustomObject("AecMassElement")
    ' draws a line from 0,0 to 1000,1000
    Set line = ThisDrawing.ModelSpace.AddLine(pt1, pt2)
        
    anchor.Reference = line ' set the linee  as the object (curve) to anchor to
    anchor.ZDistance = 200 ' set the Z Distance for the anchor
    anchor.ZRotation = Atn(1) ' Rotate by 45 degrees (Atn of 1 is 45 degrees in radians)
    mass.AttachAnchor anchor ' attach the anchor to the mass element
    
End Sub