Jump to content

Find entity on layer "unprintable".... in selected blocks


X11start

Recommended Posts

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.

Link to comment
Share on other sites

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 by BIGAL
Link to comment
Share on other sites

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)
)

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)
  )

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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)
  )

 

  • Like 1
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...