Creating Featureline using COM API IAeccLandFeatureLines:: AddFromPolyline()

By Partha Sarkar

Civil 3D .NET
API is yet to get the necessary functions to add / create featureline object. We
have a wish list logged for the same. Till we get the .NET API, let's see how
to use the existing COM API IAeccLandFeatureLines:: AddFromPolyline() in .NET
application using Interop.

 

Following
VB.NET code snippet demonstrates creation of a Featureline in AutoCAD Civil 3D
using COM API IAeccLandFeatureLines:: AddFromPolyline()

 

Using trans As Transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()
  Try
    If oAcadApp Is Nothing Then
      oAcadApp = GetObject(, "AutoCAD.Application")
    End If
  Catch ex As Exception
    ed.WriteMessage(ex.Message)
  End Try
 
  Try
    oAeccApp = oAcadApp.GetInterfaceObject("AeccXUiLand.AeccApplication.10.0")
    oAeccDoc = oAeccApp.ActiveDocument
    oAeccDB = oAeccApp.ActiveDocument.Database
 
    ' Select the 3D Polyline which you want to convert to Feature Line
 
    Dim promptEntOp As New PromptEntityOptions(vbCrLf + "Select a 3D Polyline : ")
    Dim promptEntRs As PromptEntityResult
    promptEntRs = ed.GetEntity(promptEntOp)
    If promptEntRs.Status  PromptStatus.OK Then
      ed.WriteMessage("Exiting! Try Again !")
      Exit Sub
    End If
    Dim idEnt As ObjectId
    idEnt = promptEntRs.ObjectId
 
    Dim oFtrLn As AeccLandFeatureLine = Nothing
    Dim oFtrLns As AeccLandFeatureLines = oAeccDoc.Sites.Item(0).FeatureLines
 
    Dim plineObjId As Long = idEnt.OldIdPtr
 
    oFtrLn = oFtrLns.AddFromPolyline(plineObjId, oAeccDB.FeatureLineStyles.Item(0))
 
    trans.Commit()
  Catch ex As Exception
    ed.WriteMessage("Error : ", ex.Message & vbCrLf)
  End Try
End Using

 

Once you
build your application using above code snippet and run it in Civil 3D , you
would see a Featureline being created –

 
Add_featureline_COM

 

Hope this is
useful to you!


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading