Clear Example

AEC Auto

Clear Example

Sub Example_Clear_AecProfile()

    ' This example copies a profile and uses the Clear method to
    ' remove all the rings from the new copy.
    
    ' The example looks for a profile style named
    ' "Hinged - Double - Full Lite." If you do not have this style
    ' in the current drawing, change the name of the style to one
    ' that exists in your drawing.

    Dim doc As AecBaseDocument
    Dim app As New AecBaseApplication
    Dim profileStyle As AecProfileStyle
    Dim profile As New AecProfile
    Dim copied_profile As New AecProfile
    
    Dim profileName As String
    Dim msg As String
        
    app.Init ThisDrawing.Application
    Set doc = app.ActiveDocument
    
    ' Get the specified profile style.
    On Error Resume Next
    profileName = "Hinged - Double - Full Lite"
    Set profileStyle = doc.ProfileStyles.Item(profileName)
    
    ' If an error occurred, the profile probably doesn't exist.
    If Err.Number  0 Then
        MsgBox "Profile " & profileName & " does not exist.", vbExclamation, "Clear Example"
        Exit Sub
    End If

    ' Set an AecProfile object to the style you retrieved.
    Set profile = profileStyle.profile
    
    ' Copy the profile.
    copied_profile.CopyFrom profile
    msg = "Copied profile had " & copied_profile.Rings.count & "rings." & vbCrLf
    
    ' Remove the rings in the copied profile using the Clear method.
    copied_profile.Clear
    msg = msg & "After Clear, the copied profile has " & copied_profile.Rings.count & " rings." & vbCrLf
    
    MsgBox msg, vbInformation, "Clear Example"

End Sub

End Sub