Message 1 of 8
Selection Set Sorting base on X axis
Not applicable
05-23-2017
12:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Sirs,
I'm just new on using autolisp and still learning so please help me on the dilemma i'm facing.
Basically i want to sort a selection set of polyline (rectangle) under the layer of "REF" basing on it's X axis. I copied bits of info around the net but i can't get it work the way i want it to.
Here is where i copied some of it.
[URL="http://forums.augi.com/showthread.php?137837-Sort-Selectionset-by-X-coord"]http://forums.augi.com/sh...]
(setq plt_set (ssget '((8 . "A3 REF")))) ;select layer "a3 ref"
(setq i (getint "\nEnter page no.: ") ;input page number
count 1
count1 (sslength plt_set)
ss6 (ssadd)
ss4 (list (ssname plt_set (1- count)))
)
(while (<= (1+ count) count1) ;SORT LIST BY X COORD LOW TO HIGH
(setq ss3 (list (ssname plt_set count)))
(setq ss4 (append ss4 ss3))
(setq count (1+ count))
) ;_ end of while
(vl-sort ss4
(function
(lambda (a b) (> ;; or maybe > depending on the order you want
(cadr (assoc 10 (entget a)))
(cadr (assoc 10 (entget b)))
)
)
)
)
(foreach ss5 (reverse ss4)
(setq ss6 (ssadd ss5 ss6))
)
It is still sorting by the sequence of when it was created.
Hoping for your kind help Cad Masters.
Thank you,
Ryan