Give Line direction clock wise

Give Line direction clock wise

avinash00002002
Collaborator Collaborator
295 Views
25 Replies
Message 1 of 26

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
296 Views
25 Replies
Replies (25)
Message 2 of 26

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 26

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 26

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 26

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 26

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 26

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 26

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 26

avinash00002002
Collaborator
Collaborator

Hi!

I have attached sample line drawing.

Avinash

0 Likes
Message 10 of 26

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 26

avinash00002002
Collaborator
Collaborator

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

0 Likes
Message 12 of 26

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 26

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 26

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 26

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 26

avinash00002002
Collaborator
Collaborator

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

0 Likes
Message 17 of 26

ryanatkins49056
Enthusiast
Enthusiast

Hang on @avinash00002002 I think I may have it.

Are you asking for the text labels P1 and P2 to be inserted at the end of each line?

0 Likes
Message 18 of 26

avinash00002002
Collaborator
Collaborator

NO, I don't need labels I need only define p1  and p2 points.

0 Likes
Message 19 of 26

ryanatkins49056
Enthusiast
Enthusiast

Then we all still need a little help as to what exactly you want.

You've provided us with a drawing that has a whole heap of lines at varying angles and the only common factor is that the P1 is on the left of every line.

You've now stated you only need to define P1 and P2 points.

Can you explain step by step what it is exactly you are trying to achieve?

0 Likes
Message 20 of 26

avinash00002002
Collaborator
Collaborator

I want to achieve that I need p1 point at the left side and p2 point is right side for identify cut at p1 point has left side and if cut at point p2 then it identify right side always.

0 Likes