- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need an outside perspective and some wisdom too.
I had set up a selection set and need to order it closest to the farthest object (blocks) once done. I will be generating information to load into the attribute of those blocks.
I have the code to put the data into the blocks and code to select the selection set (ss). I just can't get the code to organize the ss to work. When I do, it breaks the entity information and I can't load the attribute into the blocks.
what I found searching around brought me this old post: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-set-re-sort/td-p/871586
I can't make heads or tails of the code. Not sure how it works, but it looks very close to what I need.
Data in : my filtered ss
Data out : ss in order of closes to my origin point I selected. So I can pull the entity list with Lee Mac's selection set to list script. And load my blocks with the right information.
This is how I did it:
(setq tempss (ssget "_C" pt1 pt2 '((0 . "INSERT") (2 . "*Tracker")) );ssget i 0 );setq ;do on all blockselect (while (and tempss (< i (sslength tempss))) (setq ent (entget (ssname tempss i)) ; make a list of entities with the distance from first point px (dxf 10 ent) dist (distance pt1 px) CLIST (append CLIST (list (list dist (car ent)) ) ;list );append ); setq ;----------------- ;(print (car ent)) ;----------------- (setq i (1+ i)) );while (setq ben (LM:ss->ent tempss)) ;----------------- ;(print CLIST) ;----------------- ;sort the list with closest to farthest (setq CLIST (vl-sort CLIST (function (lambda (a1 a2) (< (car a1) (car a2)) )) ;end of lambda ) ;vl-sort );setq ;-----------------
Solved! Go to Solution.