golfdogz Posted December 13, 2013 Posted December 13, 2013 I have found the attached codes to select blocks based on matching visibity state. which i have slightly modified so that it always assumes the visibility paramter is called the default "Visibility1" the first and main command VSDB asks to select a block - however it still requires command line entering of the desired visibility state (variable "visstat"). which i want it to read that of the selected block. the following command TDB will return the name of the blocks visibility state my question is how to combine them so it is simply a matter of typing vsdb and selecting the block and done - all blocks with matching visibility state name are selected. Visibility select.lsp Quote
pBe Posted December 13, 2013 Posted December 13, 2013 (defun c:demo (/ LM:getvisibilityparametername _curvis curvis e en ess ssvis) ;; Get Visibility Parameter Name - Lee Mac ;; Returns the name of the Visibility Parameter of a Dynamic Block (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; Returns: [str] Name of Visibility Parameter, else nil (defun LM:getvisibilityparametername (blk / vis) (if (and (vlax-property-available-p blk 'effectivename) (setq blk (vla-item (vla-get-blocks (vla-get-document blk)) (vla-get-effectivename blk) ) ) (= :vlax-true (vla-get-isdynamicblock blk)) (= :vlax-true (vla-get-hasextensiondictionary blk)) (setq vis (vl-some '(lambda (pair) (if (and (= 360 (car pair)) (= "BLOCKVISIBILITYPARAMETER" (cdr (assoc 0 (entget (cdr pair)))) ) ) (cdr pair) ) ) (dictsearch (vlax-vla-object->ename (vla-getextensiondictionary blk)) "ACAD_ENHANCEDBLOCK" ) ) ) ) (cdr (assoc 301 (entget vis))) ) ) (defun _curvis (_e _vn) (vlax-get (vl-some '(lambda (l) (if (eq _vn (vla-get-propertyname l)) l ) ) (vlax-invoke _e 'GetDynamicBlockProperties) ) 'Value ) ) (if (and (setq e (ssget "_:S:E" '((0 . "INSERT")))) (setq en (vla-item (vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object)) ) (setq effname (vla-get-EffectiveName (setq e (vlax-ename->vla-object (ssname e 0))) ) ) ) ) (minusp (vlax-get en 'IsDynamicBlock)) (setq visname (LM:getvisibilityparametername e)) (setq curvis (_curvis e visname)) (setq ssvis (ssadd) ssx (ssget "X" (list (cons 2 (strcat effname ",`*U*")))) ) ) (repeat (setq i (sslength ssx)) (if (and (eq (vla-get-EffectiveName (setq es (vlax-ename->vla-object (setq ess (ssname ssx (setq i (1- i)))) ) ) ) effname ) (eq (_curvis es visname) curvis) ) (ssadd ess ssvis) ) ) ) (if curvis (sssetfirst nil ssvis) ) (princ) ) Kudos to LM for this --> getvisibilityparametername HTH Quote
golfdogz Posted December 13, 2013 Author Posted December 13, 2013 Awesome - that is the business! thankyou very much Quote
Lee Mac Posted December 13, 2013 Posted December 13, 2013 Kudos to LM for this --> getvisibilityparametername Cheers pBe! Quote
mdouglass Posted June 12, 2015 Posted June 12, 2015 Would you mind uploading your final lisp? This is exactly what I'm looking for, but I'm not adept with lisp creation. Quote
MAzri Posted June 14, 2023 Posted June 14, 2023 On 13/12/2013 at 12:03, pBe said: (defun c:demo (/ LM:getvisibilityparametername _curvis curvis e en ess ssvis) ;; Get Visibility Parameter Name - Lee Mac ;; Returns the name of the Visibility Parameter of a Dynamic Block (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; Returns: [str] Name of Visibility Parameter, else nil (defun LM:getvisibilityparametername (blk / vis) (if (and (vlax-property-available-p blk 'effectivename) (setq blk (vla-item (vla-get-blocks (vla-get-document blk)) (vla-get-effectivename blk) ) ) (= :vlax-true (vla-get-isdynamicblock blk)) (= :vlax-true (vla-get-hasextensiondictionary blk)) (setq vis (vl-some '(lambda (pair) (if (and (= 360 (car pair)) (= "BLOCKVISIBILITYPARAMETER" (cdr (assoc 0 (entget (cdr pair)))) ) ) (cdr pair) ) ) (dictsearch (vlax-vla-object->ename (vla-getextensiondictionary blk)) "ACAD_ENHANCEDBLOCK" ) ) ) ) (cdr (assoc 301 (entget vis))) ) ) (defun _curvis (_e _vn) (vlax-get (vl-some '(lambda (l) (if (eq _vn (vla-get-propertyname l)) l ) ) (vlax-invoke _e 'GetDynamicBlockProperties) ) 'Value ) ) (if (and (setq e (ssget "_:S:E" '((0 . "INSERT")))) (setq en (vla-item (vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object)) ) (setq effname (vla-get-EffectiveName (setq e (vlax-ename->vla-object (ssname e 0))) ) ) ) ) (minusp (vlax-get en 'IsDynamicBlock)) (setq visname (LM:getvisibilityparametername e)) (setq curvis (_curvis e visname)) (setq ssvis (ssadd) ssx (ssget "X" (list (cons 2 (strcat effname ",`*U*")))) ) ) (repeat (setq i (sslength ssx)) (if (and (eq (vla-get-EffectiveName (setq es (vlax-ename->vla-object (setq ess (ssname ssx (setq i (1- i)))) ) ) ) effname ) (eq (_curvis es visname) curvis) ) (ssadd ess ssvis) ) ) ) (if curvis (sssetfirst nil ssvis) ) (princ) ) Kudos to LM for this --> getvisibilityparametername HTH Hi. I am sorry to necro an almost 10 years thread. Thank you as this is working very well for the purposes! However, can the lisp be further enhanced so that the routine would works in similar way like SELECTSIMILAR? What I meant is: - able to select block first before invoke command - able to select multiple block - able to add new block into current selection Many thanks! Quote
BIGAL Posted June 14, 2023 Posted June 14, 2023 (edited) Like this. Dynamic block get-put-part2.lsp Dynamic block get-put Lee-mac.lsp Edited June 14, 2023 by BIGAL Quote
MAzri Posted June 14, 2023 Posted June 14, 2023 24 minutes ago, BIGAL said: Like this. Dynamic block get-put-part2.lsp 1.62 kB · 0 downloads I'm confused. How do I use this? I see manys function that are not defined in this routine? Quote
BIGAL Posted June 14, 2023 Posted June 14, 2023 You need the Lee-mac dynamic properties lisp as well, should have added that also. Added to post above. Quote
MAzri Posted June 15, 2023 Posted June 15, 2023 Oh thanks. but I'm still not sure how to invoke this lisp. I tried to make the INSDYNE as C:INSDYNE but nothing happened. Also, looking from the code, i guess its something to do with inserting dynamic block? Quote
BIGAL Posted June 15, 2023 Posted June 15, 2023 Maybe I am misunderstanding what your asking for the code allows you to pick a block and pick a visibilty state v's say the current displayed state, the multi radio buttons can be set so current visibilty state is pre selected. Rather than change just use that state. Look at the pbe code again. Quote
MAzri Posted June 15, 2023 Posted June 15, 2023 I see. What pBe code do is able to select a block with similar visibility state. but it only allow to do just that. For example, if a dynamic block have 3 states, say state A, B and C. I want to count total block with state B & C to count total block quantities. pBe code cannot do that. It allow only selection of single state. I need to invoke command twice to do that. I works with hundreds of block with many visibility states so its more efficient if there is such a way. Quote
Tharwat Posted June 15, 2023 Posted June 15, 2023 pBe wrote the program typically based on the OP's needs and on his volunteering time and what you are after is a custom program so I can write it for you but not for free, and if you are interested then you can send a private message to move forward. Quote
Recommended Posts
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.