X11start Posted July 20, 2023 Posted July 20, 2023 I would like to find an "elegant" way to check if, in selected blocks, there are entities on "unprintable" layers. If I find these entities, I can send an ALERT that warns me and puts a circle around the invalid block. Quote
BIGAL Posted July 21, 2023 Posted July 21, 2023 (edited) Google for any edit block entity lisp, then rather than change item, check its layer if it no plot, then draw a circle at say insertion point. Edited July 21, 2023 by BIGAL Quote
mhupp Posted July 21, 2023 Posted July 21, 2023 Made This to just display a list of block names. All Layers Are Plottable or 3 Blocks Found With Entities on Non-Plottable Layers: block name 1 block name 2 block name 3 (defun C:foo (/ laylst blklst num) (vlax-for layobj (vla-get-Layers (vla-get-activedocument (vlax-get-acad-object))) (if (= (vlax-get-property layobj 'plottable) :vlax-False) (setq laylst (cons (vla-get-name layobj) laylst)) ) ) (cond ((> (length laylst) 0) (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) ;lists all block definitions in the drawing (vlax-for obj blk ;for each object in the block (cond ((and (not (member (vla-get-name blk) blklst)) (member (vla-get-layer obj) laylst)) (setq blklst (cons (vla-get-name blk) blklst)) ) ) ) ) (if (> (setq num (length blklst)) 0) (progn (prompt (strcat "\n" (itoa num) " Blocks Found With Entities on Non-Plottable Layers:")) (foreach item Blklst (prompt (strcat "\n" item)) ) (if (> num 5) (textpage) ) ) (prompt "\nNo Blocks Found") ) ) (t (prompt "\nAll layers are Plottable") ) ) (princ) ) Quote
X11start Posted July 21, 2023 Author Posted July 21, 2023 I test the lisp, but it tells me "All layers are Plottable": it is considered "unprintable" only "Defpoints" (and inserted in the LAYLST variable), while my layer "UNPRINTABLE" is not considered. So in the attached dwg he considers me both the correct blocks. Is it possible to modify the lisp to analyze only the selected blocks and not all the blocks of the drawing? Many thanks for the answers! UNPRINTABLE.dwg Quote
X11start Posted July 21, 2023 Author Posted July 21, 2023 Maybe I can change : (vlax-for layobj (vla-get-Layers (vla-get-activedocument (vlax-get-acad-object))) (if (= (vlax-get-property layobj 'plottable) :vlax-False) (setq laylst (cons (vla-get-name layobj) laylst)) ) ) with the lisp of Jimmy Bergmark: Layer-State Quote
Tharwat Posted July 21, 2023 Posted July 21, 2023 Give this a shot and let me know. (defun c:Test (/ int sel ent add fnd obj bkn bks ) ;;----------------------------------------------------;; ;; Author : Tharwat Al Choufi ;; ;; website: https://autolispprograms.wordpress.com ;; ;;----------------------------------------------------;; (and (princ "\nSelect blocks to check for unprintable layer existed : ") (setq int -1 add (ssadd) sel (ssget '((0 . "INSERT")))) (while (setq int (1+ int) ent (ssname sel int)) (and (setq obj (tblobjname "BLOCK" (setq bkn (cdr (assoc 2 (entget ent)))))) (or (and (member bkn bks) (ssadd ent add) ) (while (and (not fnd) (setq obj (entnext obj))) (and (setq fnd (member '(8 . "UNPRINTABLE") (entget obj))) (ssadd ent add) (setq bks (cons bkn bks)) ) ) ) ) (setq fnd nil) ) ) (sssetfirst nil add) (princ) ) Quote
X11start Posted July 22, 2023 Author Posted July 22, 2023 9 hours ago, Tharwat said: Give this a shot and let me know. Your @Tharwat solution is also interesting: your lisp finds the layers contained in the blocks, regardless of whether they are printable or unprintable... It can be a valid solution: I provide a list of layers that should NOT be present in the blocks with this lisp I see if there is any block that instead contains them. But I would prefer to use the @Mhupp proposal: it is more generic and would also work with new "forbidden" layers, inserted later. Thanks anyway to both of you: I really appreciate that you wrote lisp code just for me! Quote
Tharwat Posted July 22, 2023 Posted July 22, 2023 This go ? (defun c:Test (/ int sel ent add fnd obj bkn bks ) ;;----------------------------------------------------;; ;; Author : Tharwat Al Choufi ;; ;; website: https://autolispprograms.wordpress.com ;; ;;----------------------------------------------------;; (and (princ "\nSelect blocks to check for unprintable layer existed : ") (setq int -1 add (ssadd) sel (ssget '((0 . "INSERT")))) (while (setq int (1+ int) ent (ssname sel int)) (and (setq obj (tblobjname "BLOCK" (setq bkn (cdr (assoc 2 (entget ent)))))) (or (and (member bkn bks) (ssadd ent add) ) (while (and (not fnd) (setq obj (entnext obj))) (and (setq fnd (zerop (cdr (assoc 290 (entget (tblobjname "LAYER" (cdr (assoc 8 (entget obj))))))))) (ssadd ent add) (setq bks (cons bkn bks)) ) ) ) ) (setq fnd nil) ) ) (sssetfirst nil add) (princ) ) 1 Quote
X11start Posted July 22, 2023 Author Posted July 22, 2023 Magic!! Many thanks: it works perfectly! Quote
Tharwat Posted July 22, 2023 Posted July 22, 2023 1 hour ago, X11start said: Magic!! Many thanks: it works perfectly! You're welcome anytime. 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.