@mhupp,
Just a small remark - for future better practice (challenges) :
This line :
(setq lst (mapcar '(lambda (x) (list (cdr (assoc 1 (entget x))) (cdr (assoc 10 (entget x))))) (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS)))))
Consider :
(setq lst (mapcar '(lambda (x / enx) (list (cdr (assoc 1 (setq enx (entget x)))) (cdr (assoc 10 enx)))) (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS)))))
Your verison does the same, but it' not 100% efficient... Tharwat is doint the same, but he is smartly avoiding getting DXF data twice (or more times)... In essence (entget) function calls that are unnecessary should be avoided as much as possible... The same is with (ssnamex) and perhaps with (nth) in comparison with (cdr), (car), (cadr), ... And from my experience, also when coding, try to avoid (member) function over (vl-position)... (member) will do it if you want to test presence of element in a list, but it is also getting you all elements reminders - outpur/return is also list, just truncated; in other hand (vl-position) will just return you integer number representing element position in checking list, thus much, much more faster - i.e. (if it returns number, than element belongs to list, and if it's nil not)... Here, just for better understanding - in many situations, you'll have to find presence of element in a list, but not with exact matching of values - for ex. point (10.0 10.0 10.0) belongs to list ((10.0 10.0 10.0) (10.1 10.1 10.1) ... ), but you obtained point with picking "nea" OSNAP near vertex (10.0 10.0 10.0) of a BOX [(0.0 0.0 0.0) (10.0 10.0 10.0)]... Now you need to find if point belongs to list : sometimes (member pt lst) => nil, and also (vl-position pt lst) => nil ;... Then what's the trick!!!
Well, to overcome this cases, you just have to use different ones that do the same similar :
1. (member) ... => (vl-member-if)
2. (vl-position) ... => (vl-some)
Here is how :
1. (vl-member-if '(lambda ( x ) (equal x pt fuzz)) lst) ;;; fuzz (1e-6) ;;; but like I stated - (vl-member-if) will yield you also a truncated list just like (member)...
So as opposed to this in search for efficiency, the best approach is :
2. (vl-some '(lambda ( x ) (equal x pt fuzz)) lst)
Those are just a few tricks for you to consider... In some occaisons, you may stumble at situation where you should use multiple (vl-some) calls nested in each other - nested iterations/recursions... And to get the fastest looping terminations with resulting outcomes (checked element - obtained), you'll see that (vl-some) has very justified appliance...
To get element from list by using (vl-some), just use this snippet :
(vl-some '(lambda ( x ) (if (equal x pt fuzz) x)) lst) ;;; here x element from lst was returned opposed to checking reference element pt - also fuzz factor is involved for better comparison operations...
Note that [else] statement from (if) is nil - forcing (vl-some) to continue with checking iterations all the way until complete lst was processed... If no matching found (vl-some) retuns nil also, but if (vl-some) detects matching, then result is that element X, and termination occurs imidiately when matching happened - that means if lst = (x a b c d ... ), and you apply (vl-some), you'll get X in 0.00001 millisecond, but if you have lst = (a1 a2 a3 ... a9999999 a10000000 x), (vl-some) would have to do checkings all the way until it gets X - last one... So in this and similar cases, you'll have to give appropriate feeding instruction to (vl-some), i.e. you should (reverse) lst beforehand : (setq lst (reverse lst))...