.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

0 REPLIES 0
Reply
Message 1 of 1
pavan
208 Views, 0 Replies

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

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);
}
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost