AllowVariation Example

AEC Auto

AllowVariation Example

Sub Example_AllowVariation()

    'This example will add anchor a new mass element to cell in a grid assembly.
    
    Dim grid As AecGridAssembly
    Dim poly As AecPolygon
    Dim pt As Variant
    Dim obj As AcadObject
    
    ThisDrawing.Utility.GetEntity obj, pt, "Select grid to attach to"
    If TypeOf obj Is AecGridAssembly Then
        Set grid = obj
        Set poly = ThisDrawing.ModelSpace.AddCustomObject("AecPolygon")
        Dim anchor As New AecAnchorEntToGridAssembly
        anchor.Reference = grid
        ' anchor the mass element to the first cell in the grid
        anchor.Cell = 2
        anchor.AllowVariation = True
        anchor.BottomOffset = 6
        anchor.LeftOffset = 6
        anchor.RightOffset = 6
        anchor.TopOffset = 6
        anchor.YAlignment = aecInfillAlignFrontFlush
        anchor.AdjustSizing = True
        poly.AttachAnchor anchor
    Else
        MsgBox "No Layout Grid selected", vbInformation, "Node Example"
    End If

End Sub