BlackBox 发表于 2022-7-6 22:52:38

 

 
 
 
 
Agreed.
 
 
 
 
If XAngle == 45 degrees (1/4 Pi), then subtracting it from 1/2 Pi, yields 1/4 Pi... However, adding 1/2 Pi, yields 3/4 Pi.

Tyke 发表于 2022-7-6 22:54:00

 
And the maximum angle from the Y-axis is 1/2 Pi (90°) .
 
All we need now is a response from the OP.

BlackBox 发表于 2022-7-6 23:02:09

 
We're deriving YAngle from XAngle, and not deriving XAngle from YAngle (as there is no built-in Method for YAngle), thus one must add 1/2 Pi to XAngle.

Tyke 发表于 2022-7-6 23:03:00

 
Absolutely correct
But am I missing something here, if we are deriving the angle of the line from the Y-axis it can not be greater than 1/2 Pi (90°) and by adding 1/2 Pi to the XAngle will always give a value of greater than 90°, because 1/2 Pi is 90°

BlackBox 发表于 2022-7-6 23:11:04

 
As I understand it, the OP merely requested YAngle, given the equivalent of Point2d (X, Y) for start and end points, thus simply calculating the (X)Angle of start-->end allows us to add 1/2 Pi to yield YAngle, regardless of its orientation, or quadrant.
 
Generally, AutoCAD will automagically subtract 2*Pi in the event the returned Vector2D is greater at input (i.e., at Command Line, etc.), but even that could be a simple evaluation within the Method/Function being coded here.
 
Visual LISP Example:
 

(vla-put-rotation(+ (* 0.5 pi) (* 2 pi)))
 
 
 
Now, should the OP be intending for the resultant YAngle being calculated to always be 'plan readable' that has not yet been requested, so based on the information given thus far, the aforementioned is the best, and simplest I can come up with, regardless of API being used.
 
Cheers
页: 1 [2]
查看完整版本: can't get coordinates str