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

getting angle info from line

1 REPLY 1
Reply
Message 1 of 2
dahovey
248 Views, 1 Reply

getting angle info from line

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...

dahovey@gmail.com
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: dahovey

Simple sample:
[code]
[CommandMethod("GetLineAngle")]
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.");
prOpt.AddAllowedClass(typeof(Line),true);
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);
}
}
}
}
[/code]

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