FromPolyline Example

AEC Auto

FromPolyline Example

Sub Example_FromPolyline()
    ' This example creates AEC Profile from a 2D Polyline.          
    
    Dim plineObj As   AcadPolyline
    Dim points(0 To 14) As     Double
    
    ' Define the 2D polyline points     
    ' The 3rd element is ignored     
    points(0) = 1: points(1) = 1: points(2) = 0: 
    points(3) = 1: points(4) = 2: points(5) = 0:
    points(6) = 2: points(7) = 2: points(8) = 0: 
    points(9) = 3: points(10) = 2: points(11) = 0: 
    points(12) = 4: points(13) = 4: points(14) = 0: 
        
    ' Create a 2D Polyline object in model space         
    Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)
    On Error Resume Next
    Dim ring As AecRing
    Dim profile As New AecProfile

    Dim doc As AecArchBaseDocument
    Set doc = AecArchBaseApplication.ActiveDocument
    Dim cprofiles As AecProfileStyles
    Dim profileStyle As AecProfileStyle

    Set cprofiles = doc.ProfileStyles
    Set profileStyle = cprofiles.Item("FromPolyline")
    If profileStyle Is Nothing Then
        Set profileStyle = cprofiles.Add("FromPolyline")
    End If
    Set ring = profile.Rings.Add
    ring.FromPolyline plineObj
    plineObj.delete
    Set profileStyle.profile = profile
 
End Sub