Node Example

AEC Auto

Node Example

Sub Example_Node()

    'This example will add anchor a new mass element to a 2D layout grid in the
    ' drawing.
    
    Dim grid As AecLayoutGrid2D
    Dim mass As AecMassElement
    Dim pt As Variant
    Dim obj As AcadObject
    
    ThisDrawing.Utility.GetEntity obj, pt, "Select grid to attach to"
    If TypeOf obj Is AecLayoutGrid2D Then
        Set grid = obj
        Set mass = ThisDrawing.ModelSpace.AddCustomObject("AecMassElement")
        Dim anchor As New AecAnchorEntToLayoutNode
        anchor.Reference = grid
        ' anchor the mass element to the last node on the grid
        Dim lastNode As Long
        lastNode = grid.XNodes.Count * grid.YNodes.Count
        anchor.Node = lastNode
        mass.AttachAnchor anchor
    Else
        MsgBox "No Layout Grid selected", vbInformation, "Node Example"
    End If
    
End Sub