.NET

Reply
Contributor
pavan
Posts: 14
Registered: ‎11-30-2005
Message 1 of 1 (65 Views)

how to extract line properties from autocad in C#.net

65 Views, 0 Replies
12-02-2005 10:09 PM
Hi, I am new to AutoCAD
i want a code to extract properties of a line from AUTOCAD Drawing,
I already had a code which is just giving the (X, Y, Z) coordinates of the picked point of a line,
please can anyone help me out ?

here is my code

[CommandMethod("01")]
public static void Get_Entity_Properties()
{
string s = "";
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocum ent.Editor;
Transaction trans = db.TransactionManager.StartTransaction();
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId,OpenMode.ForWrite);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForW rite);
//s = ed.GetEntity("pick the object : ").ToString().Trim();//prPtOpts
PromptEntityResult en1 = ed.GetEntity("pick the object : ");
s += "\n PromptEntityResult PROPERTIES: ";
s += "\n objectID : " + en1.ObjectId;
s += "\n GetType : " + en1.GetType().ToString();
s += "\n PickedPoint.(X, Y, Z) : " + en1.PickedPoint.X + " , " + en1.PickedPoint.Y + " , " en1.PickedPoint.Z;
try
{
Line l1 = (Line)(Object) en1;
s += "\n Line PROPERTIES: ";
s += "\n StartPoint: " + l1.StartPoint;
s += "\n EndPoint: " + l1.EndPoint;
s += "\n Status : " + en1.Status;
}
catch(System.Exception Ex)
{
s += "\n\n Error in Line Convertion : " + Ex.Message.ToString();;
}
finally{}

MessageBox.Show(s);
}
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!