Code Red > .NET

Are Line angles always positive?

(1/1)

pjm8765:
Don't get me wrong, it makes perfect sense to see the angles reported as positive values.  It's just that I look after other software which lands up with negative angles (calculated in the software, rather than the angles reported by AutoCAD) and I'm used to taking into account the (anti)clockwise direction.  It wouldn't be the first time this software I inherited had design decisions that don't make sense.

So, if I'm purely using the API to report line angles I can safely assume they will always be positive?

gile:
Hi,

From the tests I did, the Line.Angle property returns the angle in radians between the WCS X axis and the projection of the line on the WCS XY plane measured couter-clockwise in  Xthe range [0 .. 2*pi] (i.e. always positive).
You can test it by yourself.

--- Code - C#: ---        [CommandMethod("TEST")]        public static void Test()        {            var ed = Application.DocumentManager.MdiActiveDocument.Editor;            var peo = new PromptEntityOptions("\nSelect Line: ");            peo.SetRejectMessage("\nSelected object is not a Line.");            peo.AddAllowedClass(typeof(Line), true);            var per = ed.GetEntity(peo);            if (per.Status == PromptStatus.OK)            {                using (var tr = new OpenCloseTransaction())                {                    var line = (Line)tr.GetObject(per.ObjectId, OpenMode.ForRead);                    ed.WriteMessage($"\nAngle = {Converter.AngleToString(line.Angle)}");                }            }        }

pjm8765:
Thanks very, that's good to know. 

Navigation

[0] Message Index

Go to full version