Create Alignment

Create Alignment

ebarlevi
Advocate Advocate
1,419 Views
6 Replies
Message 1 of 7

Create Alignment

ebarlevi
Advocate
Advocate

Hi,

I am trying to learn NET by example. ( I know some VB)

Is there a complete code for creating an alignment from ployline ?

Thanks

0 Likes
Accepted solutions (1)
1,420 Views
6 Replies
Replies (6)
Message 2 of 7

Jeff_M
Consultant
Consultant

Sure:

C:\Program Files\Autodesk\AutoCAD Civil 3D 2013\Sample\Civil 3D API\DotNet\VB.NET\AlignmentSample

 

The same example shipped with C3D2010-2012

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 3 of 7

ebarlevi
Advocate
Advocate

Right but,

That program create and draws the polyline, I want to choose the polyline.

 

0 Likes
Message 4 of 7

Jeff_M
Consultant
Consultant
Accepted solution

Replace this code in the CreateAlignmentsByLWPolyline function:

         dObjId = CreatePolyline()
         If (dObjId.IsNull) Then
             m_Editor.WriteMessage("Sample Alignment: Error creating a polyline." + Convert.ToChar(10))
             Return False
End If

 

With this:

            Dim dObjId As ObjectId
            dObjId = SelectPolyline()
            If (dObjId.IsNull) Then
                m_Editor.WriteMessage("Sample Alignment:  Error getting a polyline." + Convert.ToChar(10))
                Return False
            End If

 

Then add this Function to the end of the class:

        Public Function SelectPolyline() As ObjectId
            Dim oPoly As ObjectId = Nothing
            Dim entOpts As New PromptEntityOptions("Select polyline:")
            entOpts.SetRejectMessage("...not a LWPolyline, try again!")
            entOpts.AddAllowedClass(GetType(Polyline), True)
            Dim entRes As PromptEntityResult = m_Editor.GetEntity(entOpts)
            If entRes.Status = PromptStatus.OK Then
                oPoly = entRes.ObjectId
            End If
            Return oPoly
        End Function

 

Jeff_M, also a frequent Swamper
EESignature
Message 5 of 7

Anonymous
Not applicable
0 Likes
Message 6 of 7

ebarlevi
Advocate
Advocate

Thank you very much !

Works like a charm

0 Likes
Message 7 of 7

Anonymous
Not applicable

Would you please mark this as "Solved" ?

 

Thanks,

0 Likes