Valued Contributor
Posts: 81
Registered: ‎07-27-2006
Message 1 of 2 (116 Views)

getting angle info from line

116 Views, 1 Replies
08-04-2006 06:13 PM
I'm trying to get the angle of a line. in autocad 2006 in you look at the properties of a line, there is a value for the angle...basicly the absolute angle of the line from start point to end point.

how do i get this angle from the .net objects...

i'm also need to get the angle between to lines...

Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 2 of 2 (116 Views)

Re: getting angle info from line

08-05-2006 01:06 AM in reply to: dahovey
Simple sample:
public void GetLineAngle()
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
Database db = HostApplicationServices.WorkingDatabase;
PromptEntityOptions prOpt = new PromptEntityOptions("\nSelect Line entity: ");
prOpt.SetRejectMessage("\nOnly Lines may be selected.");
PromptEntityResult rs = ed.GetEntity(prOpt);
if (rs.Status == PromptStatus.OK) {
using (Transaction trans = db.TransactionManager.StartTransaction()) {
Line line = trans.GetObject(rs.ObjectId, OpenMode.ForRead) as Line;
if (line != null) {
Vector3d v = line.EndPoint - line.StartPoint;
Plane plane = new Plane(new Point3d(0,0,0),new Vector3d(0,0,1));
double ang = v.AngleOnPlane(plane) / Math.PI * 180;
ed.WriteMessage("\nLine angle = {0}", ang);
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.