mhupp Posted August 9, 2021 Posted August 9, 2021 Is their a better way to filter unique block names? (if (setq SS (ssget '((0 . "INSERT")))) (progn (setq Path (getvar "DWGPREFIX")) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (if (not (vl-position (setq blkname (cdr (assoc 2 (entget e)))) blklst)) (setq blklst (cons blkname blklst)) ) ) (foreach blkname blklst Quote
Jonathan Handojo Posted August 9, 2021 Posted August 9, 2021 (edited) Not that I can think of... I think that's the most efficient. I don't know if this is better: (if (setq pth (getvar 'dwgprefix) ss (ssget '((0 . "INSERT")))) (repeat (setq i (sslength ss)) (if (not (vl-position (setq i (1- i) nm (cdr (assoc 2 (entget (ssname ss i))))) lst)) (progn ;; do your thing (setq lst (cons nm lst)) ) ) ) ) Edited August 9, 2021 by Jonathan Handojo 1 Quote
lido Posted August 10, 2021 Posted August 10, 2021 Another approach. It is not tested if the blocks are referred in the drawing, but only if they are defined! (vlax-for el (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (setq $name (vla-get-name el)) (if (/= (substr $name 1 1) "*") ;;Filter out anonymous blocks (setq LS_BLOCK_NAMES (cons $name LS_BLOCK_NAMES)) ) ) 1 Quote
Recommended Posts
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.