using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(CivilObjExplodeTest.MyCommands))]
namespace CivilObjExplodeTest
{
public class MyCommands
{
// Modal Command with localized name
[CommandMethod("MyGroup", "MyCommand", "MyCommandLocal", CommandFlags.Modal)]
public void MyCommand() // This method can have any name
{
Document adoc = Application.DocumentManager.MdiActiveDocument;
if (adoc == null) return;
Database db = adoc.Database;
Editor ed = adoc.Editor;
PromptEntityOptions peo = new PromptEntityOptions("\nУкажите объекты:");
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status == PromptStatus.OK)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTableRecord modelBtr = (BlockTableRecord)tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
Entity ent = tr.GetObject(per.ObjectId, OpenMode.ForRead) as Entity;
Type t = ent.GetType();
ed.WriteMessage(t.ToString());
if (t.ToString().Equals("Autodesk.Civil.DatabaseServices.Alignment"))
{
ObjectId idPoly = (ObjectId)t.GetMethod("GetPolyline").Invoke(ent, null);