Give Line direction clock wise

Give Line direction clock wise

avinash00002002
Collaborator Collaborator
189 Views
15 Replies
Message 1 of 16

Give Line direction clock wise

avinash00002002
Collaborator
Collaborator

Hi!

I need help that I have select a line at any direction it always give me clockwise direction p1 and p2 point.

Avinash

0 Likes
190 Views
15 Replies
Replies (15)
Message 2 of 16

Moshe-A
Mentor
Mentor

@avinash00002002  hi

 

Not sure what you mean but if you have angle in CCW, subtract 270 [ (* pi 1.5) ] from it and you will have CW

 

Moshe

0 Likes
Message 3 of 16

autoid374ceb4990
Collaborator
Collaborator

A LINE has a beginning point and end point. Were the lines drawn P1 to P2?  Try drawing one P2 to P1.

0 Likes
Message 4 of 16

Kent1Cooper
Consultant
Consultant

If I understand correctly what you want, read about the ANGBASE and ANGDIR System Variables.  With them, you can have angles measured in relation to any direction you want to be zero degrees [for example, upward instead of the default rightward direction], and in the clockwise direction instead of the default counter-clockwise.  No customization is needed.

Kent Cooper, AIA
0 Likes
Message 5 of 16

Sea-Haven
Mentor
Mentor

Like @Kent1Cooper if you type Units and in ACAD the angular values are on the right if I remember correctly. This is same thing but in Bricscad. The 90 sets the 0 angle to be North.

 

SeaHaven_0-1757983608169.png

 

0 Likes
Message 6 of 16

ryanatkins49056
Enthusiast
Enthusiast

Not entirely sure what you're after but I'll take a guess to try and help a things along.

 

(defun c:getlineangle ( / lineitem)
  (setq lineitem (entget (car (entsel))))
  (* (angle (cdr (assoc 10 lineitem)) (cdr (assoc 11 lineitem))) (/ 180 pi))
);(defun)

 The above will only work if you select a line but it will print to the command line the angle it is drawn at.

 

As always if you could provide more information as to what exactly you're after or trying to do would be helpful.

0 Likes
Message 7 of 16

Kent1Cooper
Consultant
Consultant

@ryanatkins49056 wrote:

... it will print to the command line the angle it is drawn at.

....


... but always and only the angle as measured CCW from to-the-right as zero degrees.  Using entity data, it is unaffected by the ANGBASE and/or ANGDIR System Variable settings.  Likewise with the VLA and (getpropertyvalue) approaches' "Angle" properties.

However, all that is really needed for a Line is to have ANGBASE/ANGDIR set as you want them, and simply select the Line and look at its angle as reported in the Properties palette.  That does honor whatever settings you have in those System Variables.  No command, much less any customization, is required.  But if you don't mind invoking a command, a simple LIST command also honors those settings in its report of the angle of a Line.

Kent Cooper, AIA
0 Likes
Message 8 of 16

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

.... if you type Units and in ACAD the angular values are on the right if I remember correctly. ...


Here's where they are in Acad2026:

Kent1Cooper_0-1757988720589.png

Yellow highlighting shows the initial defaults, but set them however you prefer.

Kent Cooper, AIA
0 Likes
Message 9 of 16

avinash00002002
Collaborator
Collaborator

Hi!

I have attached sample line drawing.

Avinash

0 Likes
Message 10 of 16

Moshe-A
Mentor
Mentor

@avinash00002002 

 

check now the lines angle and tell us if this is what you after (your fixed file is attached)

 

0 Likes
Message 11 of 16

avinash00002002
Collaborator
Collaborator

Lines are at any angle it may be vertical, Horizontal , no prediction for angle.

0 Likes
Message 12 of 16

Moshe-A
Mentor
Mentor

Did you check lines angle they are now in CW - isn't it what you want?

 

0 Likes
Message 13 of 16

avinash00002002
Collaborator
Collaborator

If we create a horizontal line from left to right and right to left in both cases it will change the p1, p2 point location.

0 Likes
Message 14 of 16

Moshe-A
Mentor
Mentor

@avinash00002002 ,

 

i still do not understand what you want and how this related to CCW / CW

 

you want a tool that even if you draw a line from right to left (or top to bottom) it will reverse the points ?

why it is matter?

 

 

0 Likes
Message 15 of 16

komondormrex
Mentor
Mentor

hey,

check this one

(defun c:get_line_angle (/ line_object delta_y_x) 
	(setq line_object (vlax-ename->vla-object (car (entsel "\nPick line: ")))
	      delta_y_x (reverse (mapcar '- (vlax-get line_object 'startpoint)  (vlax-get line_object 'endpoint) '(0 0)))
	)
  	(if (zerop (cadr delta_y_x))
	  (print (angtos (* -1.5 pi) 1 2)) 
	  (print (angtos (- (* 2 pi) (atan (apply '/ delta_y_x))) 1 2))
	)
  	(princ)
)
0 Likes
Message 16 of 16

avinash00002002
Collaborator
Collaborator

Thanks for your prompt reply, I need points like p1 and p2 at the end of line.

0 Likes