CenterOnNode Example

AEC Auto

CenterOnNode Example

Sub Example_CenterOnNode()

      ' This example attaches a Mass Element to a 2D Layout Grid, and centers the mass on
    ' the node.

    Dim obj As AcadObject
    Dim pt As Variant
    ThisDrawing.Utility.GetEntity obj, pt, "Select Layout Grid"
    
    If TypeOf obj Is AecLayoutGrid2D Then
        Dim grid As AecLayoutGrid2D
        Set grid = obj
        Dim mass As AecMassElement
        Set mass = ThisDrawing.ModelSpace.AddCustomObject("AecMassElement")
        Dim anchor As New AecAnchorEntToLayoutNode
        anchor.Reference = grid
        anchor.Node = 1
        anchor.CenterOnNode = True 
        mass.AttachAnchor anchor
    Else
        MsgBox "No Layout Grid selected", vbInformation, "CenterOnNode Example"
    End If
End Sub