using Autodesk.AECC.Interop.Land;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Runtime;
namespace CivilTest
{
public class CreateFeatureLine
{
[CommandMethod("CreateFeatureLineTest")]
public void CreateRun()
{
Document adoc = Application.DocumentManager.MdiActiveDocument;
Editor ed = adoc.Editor;
using (Transaction trans = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
{
try
{
IAcadApplication oAcadApp = (IAcadApplication)Application.AcadApplication;
dynamic oAeccApp = oAcadApp.GetInterfaceObject("AeccXUiLand.AeccApplication.10.3");
dynamic oAeccDoc = oAeccApp.ActiveDocument;
dynamic oAeccDB = oAeccApp.ActiveDocument.Database;
// Select the 3D Polyline which you want to convert to Feature Line
PromptEntityOptions promptEntOp = new PromptEntityOptions("\nSelect a 3D Polyline : ");
PromptEntityResult promptEntRs = ed.GetEntity(promptEntOp);
if (promptEntRs.Status != PromptStatus.OK)
{
ed.WriteMessage("Exiting! Try Again !");
return;
}
ObjectId idEnt = promptEntRs.ObjectId;
long plineObjId = (long)idEnt.OldIdPtr;
AeccLandFeatureLine oFtrLn = null;
AeccLandFeatureLines oFtrLns = oAeccDoc.Sites.Item(0).FeatureLines;
oFtrLn = oFtrLns.AddFromPolyline(plineObjId, oAeccDB.FeatureLineStyles.Item(0));
trans.Commit();
}
catch (System.Exception ex)
{
ed.WriteMessage("Error : ", ex.Message);
}
}
}
//=======================================================
//Service provided by Telerik (www.telerik.com)
//Conversion powered by NRefactory.
//Twitter: @telerik
//Facebook: facebook.com/telerik
//=======================================================
}
}