.NET

.NET

Reply
Contributor
14 Posts
0 Kudos
Registered: ‎11-30-2005
Post 1 of 1

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

66 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 interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!