I would like to select all dynamic blocks with the same name and the same "distance" value
ie I have hundreds of dynamic blocks called "ledger" with various distance values ranging from 900 to 2500.
I want to select the ones with distance value 2500, so I can
1. see where they are
2. once I have seen where they are, change their value or else do some other operation on them all at once
Is this possible. It is not possible with Qselect, is there some other way? Lisp maybe?
Michael Kovacik
AutoCAD 2018
Joburg, South Africa
please state.
same "distance" value
from where , to where.
If possible , upload a sample.dwg , please.
See if this leads to something worthwhile:
https://forums.autodesk.com/t5/dynamic-blocks-forum/quick-select-dynamic-blocks/td-p/2814162
Thanks
Nice routine for selecting all instances of a particular dynamic block.
like a Qselect for dynamic blocks.
Doesn't do what I need, however, selecting only instances with a certain distance value.
I ended up manually putting each different distance value on its own layer,
and then isolating each layer separately when I wanted to count. It took me a couple of hours.
Eattext works okay to do the counting of the different values contained in a large group, but I wanted to visually select all the instances of a certain value so I could work on them.
The eattext never seems to get to the excel file or the autocad table, always the error "deleteme" appearing in the excel cell and the autocad table not even appearing. However I screen shot the results and use the screen shot.
Try this. It creates a global variable *ss* that contains a selection set of entities that match the requirements. The selection set is also highlighted.
(defun rh:get_dbpv (b p / v)
(vl-some '(lambda (x) (and (= (strcase (vlax-get x 'propertyname)) (strcase p)) (setq v (vlax-get x 'value)))) (vlax-invoke b 'getdynamicblockproperties))
v
);end_defun
(vl-load-com)
(defun c:dbbp ( / *error* fuzz ss cnt obj bn lst)
(defun *error* ( msg )
(if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : " msg " occurred.")))
(princ)
);_end_*error*_defun
(setq fuzz 1.0e-7
ss (ssget "_X" '((0 . "INSERT")))
);end_setq
(cond (ss
(repeat (setq cnt (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt)))))
(cond ( (= :vlax-true (vlax-get-property obj 'isdynamicblock))
(setq bn (vlax-get obj (if (vlax-property-available-p obj 'effectivename) 'effectivename 'name)))
(if (= (strcase bn) "LEDGER") (setq lst (cons obj lst)))
)
);end_cond
);end_repeat
(setq *ss* (ssadd))
(foreach blk lst
(cond ( (equal (rh:get_dbpv blk "distance1") 2500 fuzz) (ssadd (vlax-vla-object->ename blk) *ss*) (redraw (vlax-vla-object->ename blk) 3)))
);end_foreach
)
(t (alert "Nothing Found"))
);end_cond
(princ)
);end_defun
I am not one of the robots you're looking for
I am not one of the robots you're looking for
This loads and runs without any problems on my system (AutoCAD 2012).
I have attached the lisp. Ensure it is saved to a trusted path in your support file or add the path where it is saved to the "trustedpaths" sytem variable. If it loads properly you should see "Type dbbp to run" on the line above the command line. If you don't see this it isn't loading properly.
The lisp requires no input, it should just highlight the blocks on the screen. If run in a empty drawing an alert should appear saying "Nothing Found"
I am not one of the robots you're looking for
I have just noticed why the code was not running. It has been copied and pasted via a text editor (probably NotePad) . This has missed the lf/cr's out so all the code is on one line, and everything after the first in line comment is considered a comment and not code. 😎
I am not one of the robots you're looking for
It has been copied and pasted via a text editor (probably NotePad)
Yes that is exactly what I did.
I now took the .lsp you posted and tried that one instead.
Still nothing happened.
not sure what's going on or how the lisp is supposed to work.
Thanks for your help anyway.
Mike
The lisp should highlight every block in the drawing that meets the criteria you supplied, and makes a global variable *ss* which contains a selection set of all the block entities that meet the criteria.
I am not one of the robots you're looking for
Can't find what you're looking for? Ask the community or share your knowledge.