Search the Community
Showing results for tags 'sorting'.
Found 4 results
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. http://forums.augi.com/showthread.php?137837-Sort-Selectionset-by-X-coord (setq plt_set (ssget '((8 . "REF")))) ;select layer "REF" (setq 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
nalsur8 posted a topic in AutoLISP, Visual LISP & DCLSeparate/copy layer to other place by user pick point then sorting them horizontal below code not sorting horizontal.how to change the code, become horizontal (see image attached) (defun c:test1 ( / _move d ss l lst ) (vl-load-com) (defun _move ( obj p q dist ) (vla-move (setq obj (vla-copy obj)) (vlax-3D-point p) (vlax-3D-point q)) (vla-move obj (vlax-3D-point '(0. 0. 0.)) (vlax-3D-point (list dist 0. 0.))) ) (if (and (ssget "_:L") (setq p1 (getpoint "\nBase Point: ")) (setq p2 (getpoint "\nDesired Location: " p1)) (setq p1 (trans p1 1 0) p2 (trans p2 1 0)) ) (progn (vlax-for obj (setq d 10. ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (_move obj p1 p2 (cond ( (cdr (assoc (setq l (vla-get-layer obj)) lst)) ) ((cdr (assoc (vl-string-right-trim "D" l) lst))) ((cdr (assoc (strcat l "D") lst))) ( (setq lst (cons (cons l (setq d (- d 650.))) lst)) d ) ) ) ) (vla-delete ss) ) ) (princ) )
Hey guys, Kind of a random question, but what are some known issues of why a tree can not be sorted? I'm referring to the "Alpha Sort Component" in the "Productivity" section of the "Assemble" tab. It sucks when I'm forced to work in other people's projects and go to do it and it fails. Do things like component patterns cause it to hang up? I'm kind of picky when it comes to my tree, and I know I can generally right click and "Find in Browser," but I like it to be nice and organized!
Hey everyone. Could use a little assistance here. Not sure if this is even possible, but I assume it should be. I'm still in the "i know enough LISP just to be dangerous, but slightly useful" stage I have a LISP routine that collects 5 variables from the user (r1,r2,r3,r4,r5). (setq r1 (getint "\nEnter First Rev Line Number use ZERO for NONE: ")) (setq r2 (getint "\nEnter Second Rev Line Number use ZERO for NONE: ")) (if (= r2 0)(setq r3 0)(setq r3 (getint "\nEnter Third Rev Line Number use ZERO for NONE: "))) (if (= r3 0)(setq r4 0)(setq r4 (getint "\nEnter Fourth Rev Line Number use ZERO for NONE: "))) (if (= r4 0)(setq r5 0)(setq r5 (getint "\nEnter Fifth Rev Line Number use ZERO for NONE: "))) What I would like to do with them, is sort them by their values, putting the highest value first, then sorting in reverse. Can anyone offer any insight on this? Thank you in advance!