.NET

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

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

57 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);
}

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community