satishrajdev Posted March 16, 2017 Posted March 16, 2017 Hi, I'm trying to create a code for draftsight, But as we know it supports only AutoLISP not Visual LISP. I'm stuck at 1 point where I want to sort point list in X & Y direction, we can use VL-SORT function for that but I dont find any autolisp function substitute for that. I hope I'll get some ideas from you. Waiting for your input. Regards, Satish Quote
rkmcswain Posted March 16, 2017 Posted March 16, 2017 You might start here: http://www.faqs.org/faqs/CAD/autolisp-faq/part1/section-9.html Quote
Grrr Posted March 16, 2017 Posted March 16, 2017 You might start here: http://www.faqs.org/faqs/CAD/autolisp-faq/part1/section-9.html Aren't those written by gile ? In this thread. BTW heres some easy version: ; _$ (SortPointList 'x '((0 1 2) (2 0 1) (1 2 0))) -> ((0 1 2) (1 2 0) (2 0 1)) ; _$ (SortPointList 'y '((0 1 2) (2 0 1) (1 2 0))) -> ((2 0 1) (0 1 2) (1 2 0)) ; _$ (SortPointList 'z '((0 1 2) (2 0 1) (1 2 0))) -> ((1 2 0) (2 0 1) (0 1 2)) (defun SortPointList ( mode pL ) (cond ( (not (vl-position mode '(x y z))) (princ "\nInvalid mode.") ) (T (vl-sort pL '(lambda (p1 p2) (apply '< (mapcar (cdr (assoc mode '((x . car)(y . cadr)(z . caddr)))) (list p1 p2))) ) ) ) ); cond ); defun Quote
Lee Mac Posted March 16, 2017 Posted March 16, 2017 Here's another implementation of quicksort, the code could be modified to accept an arbitrary sorting function. Quote
rkmcswain Posted March 17, 2017 Posted March 17, 2017 Aren't those written by gile ? In this thread. IDK. The thread you referenced is from 2011, and @gile makes no reference to the origin of this code. The code in my link is dated from July 1998. Quote
satishrajdev Posted March 19, 2017 Author Posted March 19, 2017 BTW heres some easy version: ; _$ (SortPointList 'x '((0 1 2) (2 0 1) (1 2 0))) -> ((0 1 2) (1 2 0) (2 0 1)) ; _$ (SortPointList 'y '((0 1 2) (2 0 1) (1 2 0))) -> ((2 0 1) (0 1 2) (1 2 0)) ; _$ (SortPointList 'z '((0 1 2) (2 0 1) (1 2 0))) -> ((1 2 0) (2 0 1) (0 1 2)) (defun SortPointList ( mode pL ) (cond ( (not (vl-position mode '(x y z))) (princ "\nInvalid mode.") ) (T (vl-sort pL '(lambda (p1 p2) (apply '< (mapcar (cdr (assoc mode '((x . car)(y . cadr)(z . caddr)))) (list p1 p2))) ) ) ) ); cond ); defun Thanks Grrr for your effort but I mentioned above that I dont want to use VL functions. Here's another implementation of quicksort, the code could be modified to accept an arbitrary sorting function. Thanks you Quote
Grrr Posted March 19, 2017 Posted March 19, 2017 Thanks Grrr for your effort but I mentioned above that I dont want to use VL functions. Ah, sorry about that - I didn't read carefully. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.