Hello,
I am trying to select all blocks of a certian name. I am using the following:
(setq ss1bk (ssget "_X" (list (cons 2 blkname))))
My issue is that this will not select any dynamic or attribute blocks that are not at the default insert state.
Does anyone know how to select all of a block by name including reguardless of current state?
Thanks.
Tharwat,
Thanks for the reply.
The edit made to your routine does not allow me to get past the select block mode, the routine ends as soon as a block is selected.
@dortega4226 wrote:Tharwat,
Thanks for the reply.
The edit made to your routine does not allow me to get past the select block mode, the routine ends as soon as a block is selected.
Pick the button select and and you prompted to pick a block , pick one then the routine should return a list of layers in the popup list when you being brought back to dialog .
is not that what did happen by the program ?
@_Tharwat wrote:
Pick the button select and and you prompted to pick a block , pick one then the routine should return a list of layers in the popup list when you being brought back to dialog .
is not that what did happen by the program ?
Here is a quick video of what happens...
@_Tharwat wrote:
Maybe the hyperlink affects on the block and the function ssget could not differ between them , so try on another block .
This is what happens when selecting several different blocks...
Ahh, that is it. Good catch. Thank you very much for your help.
Try this .
I don not understand why you want to list the layers in a list after picking a specific block ?
(defun c:GetBlocks (/ *error* D f id run go sel blocks s lst ss i layer sn vl ss1 en bn go BlockTable ) ;; Author: Tharwat Al Shoufi ;; ;; GetBlocks Program ;; ;; Date : 08. August. 2014 ;; (defun *error* (msg) (if (and D (setq D (findfile D))) (vl-file-delete D) ) (if (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*") (princ msg) (princ (strcat "\n ** Error : " msg " **")) ) ) ;; ;; (defun BlockTable (/ i a l nm) (while (setq i (tblnext "BLOCK" (not i))) (if (not (wcmatch (setq nm (cdr (assoc 2 i))) "`**")) (setq l (cons nm l)) ) ) (setq l (acad_strlsort l)) ) ;; ;; (if (ssget "_X" '((0 . "INSERT"))) (setq run t) (alert "No blocks found in this drawing !!") ) (if (and run (setq D (vl-filename-mktemp nil nil ".dcl")) (setq f (open D "w")) ) (progn (write-line (strcat "test : dialog { label = \"Highlight Blocks\"; width = 36;" "spacer;" ": boxed_column { label = \"Options\";" ": button { label = \"Select >>\"; key = \"sbk\";}" "spacer;" ": popup_list { label = \"Block:\"; key = \"bl\"; width = 32;}" "spacer;" ": popup_list { label = \"Layer:\"; key = \"lay\"; width = 32;}}" "spacer;" ": boxed_radio_column { label = \"Selection Way:\";" ": radio_button { label = \"Global\"; key = \"g\"; value = \"1\";}" ": radio_button { label = \"Window\";key = \"w\";}}" "spacer;" ": boxed_row { label = \"Action\"; fixed_width = true; alignment = centered;" ": button { label = \"Okay\"; key = \"oki\"; is_default = true; height = 1.75; width = 12;}" ": button { label = \"Exit\"; key = \"esc\"; is_cancel = true; height = 1.75; width = 12;}}}" ) f ) (close f) ) ) (if (or (not D) (not (new_dialog "test" (setq id (load_dialog D)))) ) (progn (if (> id 0) (unload_dialog id) ) (if (and D (setq D (findfile D))) (vl-file-delete D) ) ) (progn (setq blocks (BlockTable)) (start_list "bl") (mapcar 'add_list blocks) (end_list) (if *layers* (progn (start_list "lay") (mapcar 'add_list (acad_strlsort *layers*)) (end_list) ) ) (if (and *GetBlockName* (tblsearch "BLOCK" *GetBlockName*)) (set_tile "bl" (itoa (vl-position *GetBlockName* blocks))) ) (action_tile "sbk" "(setq sel t *layers* nil)(done_dialog)") (action_tile "oki" "(setq lst (mapcar 'get_tile (list \"bl\" \"lay\" \"g\" \"w\")) bn (nth (atoi (car lst)) blocks) go t *GetBlockName* nil *layers* nil) (done_dialog)" ) (action_tile "esc" "(setq go nil) (done_dialog)") (start_dialog) (unload_dialog id) (vl-file-delete D) ) ) (if (and sel (princ "\n Pick Block :") (setq s (ssget "_+.:S:E" '((0 . "INSERT")))) (setq *GetBlockName* (vla-get-effectivename (vlax-ename->vla-object (ssname s 0)) ) ) (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 (strcat "`*U*," *GetBlockName*)) ) ) ) ) (progn (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i))) vl (vlax-ename->vla-object sn) ) (if (and (eq (vla-get-effectivename vl) *GetBlockName*) (not (member (setq layer (cdr (assoc 8 (entget sn)) ) ) *layers* ) ) ) (setq *layers* (cons layer *layers*)) ) ) (c:GetBlocks) ) ) (if (and bn go (setq ss1 (ssget (if (eq (caddr lst) "1") "_X" "_:L" ) (list '(0 . "INSERT") ;;; (cons 8 ;;; (if (eq (cadr lst) "0") ;;; "*" ;;; (nth (atoi (cadr lst)) layers) ;;; ) ;;; ) (cons 2 (strcat "`*U*," bn)) ) ) ) ) (progn (repeat (setq i (sslength ss1)) (if (not (eq (vla-get-effectivename (vlax-ename->vla-object (setq en (ssname ss1 (setq i (1- i)))) ) ) bn ) ) (ssdel en ss1) ) ) (sssetfirst nil ss1) ) ) (princ) )
Tharwat,
This worked, however, the selection should still be based off of the Layer selection.
Example:
You're very close, sorry if I'm not being clear enough for you. I'm trying to explain as best I can.
@dortega4226 wrote:Tharwat,
This worked, however, the selection should still be based off of the Layer selection.
Example:
- Select Block named Casework
- All Casework blocks are selected
- Layer list is minimized to show only layers used by Casework block(s)
- When "-- On Any Layer --" is selected all Casework blocks are selected
- When a specific layer is selected, 34" Tall Base Cabinet, then only the Casework blocks on the 34" Tall Base Cabinet layer are selected
You're very close, sorry if I'm not being clear enough for you. I'm trying to explain as best I can.
I think you can not say close or even very close because i have been asking you what to do with the layer list after retrieving them from blocks and you did not answer my question at all and I updated the routine according to what you believe in and not to what I do .
I am sorry , I would end up to this point .
Tharwat,
Thanks for all the help. I think you're taking offense to something that stemmed from a misunderstand. I think I've tried to explain it, but I was unsuccessful in explaining and understanding the questions you had asked. Thank you for your hard work, I won't discount anything you have done for me already. You have done an excellent job.
Is there anyone else that might be able to decifer what it is I'm trying to achieve and try to give it a go?
Hello pbejse
I'm using your selblock lisp & it's good
However I'ne changed a line near the end to display how many block have been selected
Ideally I'd like to put in the name of the blocks to be displayed too, however I'm having trouble with that. It's easy enough with vlide to work out that the name of the block is stored in variable BN but how do I add it to the attached code?
I've tried (getvar bn) & (entlget bn) without success
I bet it's simple but I don't know how to do it
) (sssetfirst nil selection) (princ (strcat "\n "(itoa (sslength selection))" Blocks [CODE TO DISPLAY NAME OF BLOCK HERE] Selected")) (princ) )
@sbanister wrote:
....
However I'ne changed a line near the end to display how many block have been selected
Ideally I'd like to put in the name of the blocks to be displayed too, however I'm having trouble with that. It's easy enough with vlide to work out that the name of the block is stored in variable BN but how do I add it to the attached code?
....
Since Block names are text strings, you should be able to add the BN variable in with other strings directly in the (strcat) function, e.g.:
(princ (strcat "\n "(itoa (sslength selection))" Blocks " BN " Selected"))
Ah, thank you Kent
I thought it would be simple
However not that simple !
Hey!
I tried this code and if i "select" the block it works great.
But if i try to select a block from the dropdown and "ok" it gives me: ** Error : bad argument type <NIL> ; expected <CONS> at [nth] **
Also can i change to width of the dialog box to something like 100%? I want to see the full names of the blacks in dropdown.
Cheers
Sry, i didnt see that there is a page 3 with an updated version. this one works great thx! just the question about the width is still open.
Is there a way to expand on this command, so that you can enter the name of the block in the command line vs. finding the name in the pull down menu?
This is a great command by the way.
Thank you
Anderson51
@anderson51 wrote:
Is there a way to expand on this command, so that you can enter the name of the block in the command line vs. finding the name in the pull down menu?
This is a great command by the way.
Thank you
Anderson51
Hi,
I worked hard on this program on my own volunteering time, so if you want me to modify the program as per your requirements then just contact me on my website as shown in my signature or as a private message.