CopyFrom Example

AEC Auto

CopyFrom Example

Sub Example_CopyFrom_AecProfile()

    ' This example copies an existing profile using the CopyFrom method.
    
    ' 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, "CopyFrom  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   
    MsgBox msg, vbInformation, "CopyFrom Example"

End Sub