.NET

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

getting angle info from line

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

dahovey@gmail.com
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 2 of 2 (108 Views)

Re: getting angle info from line

08-05-2006 01:06 AM 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]

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