• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

lisp to determine whether a polyline is designed clockwise or anticlockwise

  • Thread starter Thread starter wind_skin
  • Start date Start date

wind_skin

Guest
Hello, I ask you experts if there is a lisp (with .lsp extension) that can determine whether a closed polyline has been drawn clockwise or anti-clockwise.
Thank you in advance.
 
This is a program I created time ago to check whether the polyline is clockwise or anti-clockwise. Please note that if the polyline is created with the _bpoly command is always anti-clockwise. if you are interested I also have the program to reverse the sense of polylinea (created to use it on autocad versions that did not have the reverse option of the editpl command).
 

Attachments

I came across the doslib.arx library, which can be loaded free of charge and easily in autocad, which contains a mine of advanced functions, well documented.
among these the dos_plinewinding function that solves your problem.

(dos_plinewinding entity)
the entity name of a closed polyline.

return
> 0 if the polyline winds to the left.
< 0 if the polyline winds to the right.
0 if unable to determine the winding.
nil on error.

example.
command: (dos_plinewinding (car (entsel "\nselect a closed polyline:"))
-1
 
the purpose was to solve everything without installing additional libraries. It happened to me again to propose doslib to solve another problem. the interlocutor has categorically refused. . .
 
the purpose was to solve everything without installing additional libraries. It happened to me again to propose doslib to solve another problem. the interlocutor has categorically refused. . .
and what should be the problem? are free, they are not heavy.. .
and then the express tools are not also an external library?
 
often my programs must create them without the help of external libraries. Unfortunately, I must also consider the possibility that someone has not installed express tools, although very inconvenience.
But I must say that this is a bit different here.
 
I thank both for the help and interest; I will try and update you. In fact, I need a function to insert into a little program that I intend to write and that I will need to produce a gcode for the tool path of a cnc directly from autocad. It is good that there are specific software for this purpose, but I would also like to try.
Thanks again: you are very kind.
 
This is a program I created time ago to check whether the polyline is clockwise or anti-clockwise. Please note that if the polyline is created with the _bpoly command is always anti-clockwise. if you are interested I also have the program to reverse the sense of polylinea (created to use it on autocad versions that did not have the reverse option of the editpl command).
confutatis, I just tried to load the lisp you kindly attached, but it gives me the following error in loading phase "; error: incorrect list in the input".
I tried both with 2008 and 2011. more precisely, the viewer is the following:
"command: _appload plor.lsp loaded. "
"command: ; error: wrong list in input"
 
once so much that I remember the (vl-load-com), I forget the brackets, bah...
thanks confutatis, your program works egregiously with all the types of polylinea that I had the opportunity to try, except those closed composed only by a circle arc and a segment (it is not because).
Thanks again, you were very kind and precious.
 
with only two vertices how do you understand the clock or anti-clockwise? I thought the least was three...
 
with only two vertices how do you understand the clock or anti-clockwise? I thought the least was three...
I agree with you: it takes at least three vertices. the third summit (the missing one) could be the average point of the circle arc.
 
the third summit (the missing one) could be the average point of the circle arc.
I was inspired and created this: in all two-sided polylines and one of the two sides is a circle arc, on the same a third summit is inserted on the average point.
all this by exploiting the powerful vlisp functions of entity management.
 

Attachments

I was inspired and created this: in all two-sided polylines and one of the two sides is a circle arc, on the same a third summit is inserted on the average point.
all this by exploiting the powerful vlisp functions of entity management.
hi confutatis, I tried the program you wrote, but I didn't get the desired result (I don't know where I'm wrong). I attach a file containing an example of closed polylinea composed of a circle arc and a segment: If you have time (I don't want to take advantage of your kindness), take a look.
Thank you.
 

Attachments

No, you're not wrong, I'm the one who didn't consider other possibilities. in the specific case the original vertices were not two but three, the last was coincident with the first, but, for the purposes of programming, a closed polyline with n vertices is different from an open polyline with n+1 vertices, of which the first and the last coincidence, even if to video are identical.
 

Attachments

confutatis, I tried your program and it works. In summary, I believe I have understood that, if you have to deal with a closed polylinea composed of a circle arc and a segment, you must first start "aumver" and then bend the orientation by "plor". correct me if I'm wrong. Now I will try to join the two programs in one: I hope I can.
thanks for your availability and kindness.
 
Yes, I actually left the two separate programs, since aumver could only serve me occasionally. Anyway, if you want to have fun joining them, go ahead! :smile:
 
the time/time sense only makes sense on closed polylines. What's the point of giving an open polyline? for these just the reverse command. at the limit I can remove from the selection all the open polylines. . .
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top