Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create Alignment

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
ebarlevi
996 Views, 6 Replies

Create Alignment

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

6 REPLIES 6
Message 2 of 7
Jeff_M
in reply to: ebarlevi

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
Message 3 of 7
ebarlevi
in reply to: Jeff_M

Right but,

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

 

Message 4 of 7
Jeff_M
in reply to: ebarlevi

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
Partha.Sarkar
in reply to: ebarlevi

Please take a look at the following :

 

http://adndevblog.typepad.com/infrastructure/2012/06/do-you-want-to-programmatically-convert-polylin...

 

Hope this helps.



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 6 of 7
ebarlevi
in reply to: Jeff_M

Thank you very much !

Works like a charm

Message 7 of 7
Partha.Sarkar
in reply to: ebarlevi

Would you please mark this as "Solved" ?

 

Thanks,



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report