AttachEntity Example

AEC Auto

AttachEntity Example

Sub Example_AttachEntity()

    ' This example will make a mass element and and anchor it to a line.
    
    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 line as the object (curve) to anchor to
    anchor.AttachEntity mass ' attach the mass element to the anchor

End Sub