AcadLine.Angle verses regular function?

AcadLine.Angle verses regular function?

Anonymous
Not applicable
460 Views
8 Replies
Message 1 of 9

AcadLine.Angle verses regular function?

Anonymous
Not applicable
Hi

At the moment I have a series of coordinate pairs that represent linear data. I need the angle of each of these "segments" and at the moment I create a temporary line and use the lines .Angle method to give me the values.

This works fine but I wondered if I can acheive the same thing WITHOUT having to create the line entities. I can't use AngleFromXAxis because that returns a different angle. But must be the exact same value that AcadLine.Angle returns. I want the same, from a function that is passed 2 arrays of double(0 to 2) entities.

Possible?

If so, I think it would improve my macros overall performance as I would not need to create all these temporary entities and delete them.

Thanks in advance.

Andrew
0 Likes
461 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
Trig should do it.

http://en.wikipedia.org/wiki/Sohcahtoa

As I read the help file, both of the methods you metioned return the angle
from the X axis. I believe one is given in degrees and the other is probably
given in radians.

Gary
0 Likes
Message 3 of 9

Anonymous
Not applicable
You can use AngleFromXAxis, if you translate the
endpoint coordinate to the origin, by the inverse
displacement of the startpoint.

In other words,

To find the angle of a line starting at p1,
and passing through p2,

v[0] = p2[0] - p1[0]
v[1] = p2[1] - p1[1]
v[2] = p2[2] - p1[2]

Then you can use v with AngleFromXAxis, or
you can use trig functions directly.

Creating and using 'temporary' entities to do very
basic geometric calculatiions is a horrible kludge
that needlessly wastes valueable resources.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5747752@discussion.autodesk.com...
Hi

At the moment I have a series of coordinate pairs that represent linear data. I need the angle of each of these "segments" and at the moment I create a temporary line and use the lines .Angle method to give me the values.

This works fine but I wondered if I can acheive the same thing WITHOUT having to create the line entities. I can't use AngleFromXAxis because that returns a different angle. But must be the exact same value that AcadLine.Angle returns. I want the same, from a function that is passed 2 arrays of double(0 to 2) entities.

Possible?

If so, I think it would improve my macros overall performance as I would not need to create all these temporary entities and delete them.

Thanks in advance.

Andrew
0 Likes
Message 4 of 9

Anonymous
Not applicable
AFAIK, the Angle property should return the same value
that AngleFromXAxis returns given the endpoints of the
line.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5747752@discussion.autodesk.com...
Hi

At the moment I have a series of coordinate pairs that represent linear data. I need the angle of each of these "segments" and at the moment I create a temporary line and use the lines .Angle method to give me the values.

This works fine but I wondered if I can acheive the same thing WITHOUT having to create the line entities. I can't use AngleFromXAxis because that returns a different angle. But must be the exact same value that AcadLine.Angle returns. I want the same, from a function that is passed 2 arrays of double(0 to 2) entities.

Possible?

If so, I think it would improve my macros overall performance as I would not need to create all these temporary entities and delete them.

Thanks in advance.

Andrew
0 Likes
Message 5 of 9

Anonymous
Not applicable
They don't seem to. I have tested it.

Andrew
0 Likes
Message 6 of 9

Anonymous
Not applicable
This is probably what you want. You pass string values from a list and make them into points.
[code]
Sub test()
Debug.Print LineAngle("0", "4.0002", "6.04", "7.9")
End Sub


Function LineAngle(X1, Y1, X2, Y2)

Dim Pt1(2) As Double
Dim Pt2(2) As Double
Pt1(0) = CDbl(X1): Pt1(1) = CDbl(Y1)
Pt2(0) = CDbl(X2): Pt2(1) = CDbl(Y2)
LineAngle = ThisDrawing.Utility.AngleFromXAxis(Pt1, Pt2)

End Function
[/code]
0 Likes
Message 7 of 9

Anonymous
Not applicable
I don't see how that differs from just passing in line.StartPoint, line.EndPoint.

There have been a variety of responses here and everyone thinks different things.

I think the differenc eis that one does an angle and one does a bearing. The two functions are not the same.

And one of then is relative to ANGBASE and ANGDIR (AngleFromXAxis). The other isn't.

As for the other suggestions, I have not tried them as I am not a trig guru. But thanks for suggestion resources and things.

Andrew
0 Likes
Message 8 of 9

Anonymous
Not applicable
You are wrong.

ANGBASE and ANGDIR have no effect on the result
of AngleFromXAxis or the AutoLISP (angle) function.

AngleFromXAxis knows nothing about the ANGBASE
or ANGDIR system variables. The function performs
a basic trig operation that you can easily perform
yourself.

Your error may be that you may using points that are
not in the WCS (perhaps obtained vai the the AutoLISP
(getpoint) function in a non-world UCS).

In VBA, the Getpoint() method returns a WCS point,
and when passing the two ends of a line obtained
via that method to AngleFromXAxis, the result is
the same as the Line's Angle property.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5748932@discussion.autodesk.com...
They don't seem to. I have tested it.

Andrew
0 Likes
Message 9 of 9

Anonymous
Not applicable
Tony Tanzillo wrote:

> You are wrong.
>
> ANGBASE and ANGDIR have no effect on the result
> of AngleFromXAxis or the AutoLISP (angle) function.
>
> AngleFromXAxis knows nothing about the ANGBASE
> or ANGDIR system variables. The function performs
> a basic trig operation that you can easily perform
> yourself.
>
> Your error may be that you may using points that are
> not in the WCS (perhaps obtained vai the the AutoLISP
> (getpoint) function in a non-world UCS).
>
> In VBA, the Getpoint() method returns a WCS point,
> and when passing the two ends of a line obtained
> via that method to AngleFromXAxis, the result is
> the same as the Line's Angle property.

Point taken about then giving same values.

Sorry.

None-the-less... setting ANGDIR and ANGBASE does alter the values
these methods return - even if they return the same value.

But thanks for the observation!
0 Likes