Add Example

AEC Auto

Add Example

Sub Example_Add_AecProfile()

    ' This example defines a custom profile consisting of
    ' of two triangles, one within the other.

    Dim doc As AecBaseDocument
    Dim app As New AecBaseApplication
    Dim profileStyle As AecProfileStyle
    Dim profile As New AecProfile
    Dim profileName As String
        
    app.Init ThisDrawing.Application
    Set doc = app.ActiveDocument
    
    ' Get existing or add a new profile style.
    On Error Resume Next
    profileName = "BOOBYPRIZE"
    Set profileStyle = doc.ProfileStyles.Add(profileName)

    ' If error occurred, the profile probably already exists.
    If Err.Number  0 Then
        Err.Clear
        On Error GoTo 0
        Set profileStyle = doc.ProfileStyles.Item(profileName)
    End If

    ' Define definition points for rings.
    Dim OuterPts(0 To 7) As Double
    Dim InnerPts(0 To 7) As Double

    OuterPts(0) = 0: OuterPts(1) = 0
    OuterPts(2) = 648: OuterPts(3) = 0
    OuterPts(4) = 324: OuterPts(5) = 324
    OuterPts(6) = 0: OuterPts(7) = 0

    InnerPts(0) = 120: InnerPts(1) = 60
    InnerPts(2) = 528: InnerPts(3) = 60
    InnerPts(4) = 324: InnerPts(5) = 264
    InnerPts(6) = 120: InnerPts(7) = 60

    ' Create and set the outer ring.
    Dim ring1 As AecRing
    Set ring1 = profile.Rings.Add
    ring1.FromPoints (OuterPts)
    ring1.Void = False

    ' Create and set the inner ring.
    Dim ring2 As AecRing
    Set ring2 = profile.Rings.Add
    ring2.FromPoints (InnerPts)
    ring2.Void = True

    ' Set the profile definition.
    Set profileStyle.profile = profile
    
    MsgBox ("Profile """ & profileName & """ created.")

End Sub