Jump to content

Recommended Posts

Posted

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

Posted

Wow... Thanks a lot... :beer:

Posted

 

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 

Posted
Here's another implementation of quicksort, the code could be modified to accept an arbitrary sorting function.
Posted

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 :)

Posted
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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...