Originally Posted by
peysey
Hi guys,
When I want to select all blocks with a specific name in drawing area + all layouts, I use this command:
(sssetfirst nil (ssget "_x" '((0 . "INSERT") (2 . "123"))))
With this code I have selected all blocks with the name "123" in the model space and also all layouts.
However, this does not work with Dynamic blocks... Is there also a way to select dynamic blocks?
Originally Posted by
peysey
Thank you,
I found those already, but they don't answer the question. I want to sellect dyn blocks in modelspace + layout.
If I would like to select them only in modelspace, I could use 'selectsimilar', that also works for dyn blocks. However that is another case.
Not sure that you understand the difference between a Pickset and a SelectionSet.
SelectSimilar 'selects' (onscreen) a Pickset - the set of entities that is actively 'selected' (picked) onscreen, that shows up in Properties Pane, etc. You can only 'select' (pick, onscreen) entities on your current tab (model, layout, etc).
SelectionSets are programmatic and when used with "_x" selection method, contain entities from the entire database, which includes model, layout, etc. These entities can be iterated, and even modified (programmatically), but cannot be 'selected' (picked, onscreen) if they do not reside on the active tab (CTAB sysvar).
To add to Opie's and cadtag's apt posts, please consider this example:
Code:
(vl-load-com)
(defun c:BlockCount (/ blockName i ss)
(if
(and
(setq blockName (getstring "\nEnter block name: "))
(setq blockName (strcase blockName))
(ssget "_x" '((0 . "INSERT")))
)
(progn
(setq i 0)
(vlax-for x (setq ss (vla-get-activeselectionset
(vla-get-activedocument (vlax-get-acad-object))))
(if (= blockName (strcase (vla-get-effectivename x)))
(setq i (1+ i))
)
)
(prompt (strcat "\n** " (itoa i) " blocks found ** "))
(vla-delete ss)
)
)
(princ)
)