It was only recently that I was able to enjoy the new Muppets film. It was a great family movie and much like the Muppets I grew up with. Anyways, that is what inspired the title of this article, the song "Are You A Man or A Muppet" more specifically.
Note: This article does not work for those using AutoCAD for Mac because it does not support ActiveX.
Using AutoLISP, you can access the Blocks table in the current drawing and determine the types of blocks in a drawing. Blocks can be the kind that you insert via the INSERT command, attach as an xref, or those that are containers for the geometry on a layout such as Model or Layout1. The same logic can be applied to determine the types of blocks inserted into model or paper space.
The following code demonstrates how to determine the block type for each block in the current drawing using the IsXref, IsLayout, and IsDynamicBlock methods/properties. It also steps through the objects in each block to see if it contains attributes or not.
(defun c:WhatKindOfBlockAmI ( / acadObj doc msg block)
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
(setq msg "")
;; Step through all the blocks in the Blocks table
(vlax-for block (vla-get-Blocks doc)
;; Standard or dynamic block?
((and (= (vla-get-IsLayout block) :vlax-false)
(= (vla-get-IsXRef block) :vlax-false))
(if (= (vla-get-IsDynamicBlock block) :vlax-false)
(setq msg (strcat msg (vla-get-Name block) ": Standard"))
(setq msg (strcat msg (vla-get-Name block) ": Dynamic"))
;; Has attributes?
(setq attsExist "")
(vlax-for ent block
(if (= (vla-get-ObjectName ent) "AcDbAttributeDefinition")
(setq attsExist " with attributes")
(setq msg (strcat msg attsExist))
((= (vla-get-IsXRef block) :vlax-true)
(setq msg (strcat msg (vla-get-Name block) ": Xref"))
(if (= (vla-get-IsLayout block) :vlax-true)
(setq msg (strcat msg (vla-get-Name block) " and layout"))
((= (vla-get-IsLayout block) :vlax-true)
(setq msg (strcat msg (vla-get-Name block) ": Layout only"))
(setq msg (strcat msg "\n"))
;; Display the block information for this drawing
(alert (strcat "This drawing contains blocks of the following types: " msg))