Hello everyone,
I've been working with AutoCAD for quite some time and have gained experience in customizing and automating tasks using Visual LISP. Currently, I'm dealing with some issues related to dynamic blocks and could use some assistance. Specifically, I'm encountering challenges with managing and manipulating the properties of dynamic blocks using Visual LISP.
I'm particularly interested in learning how to read and update various properties and parameters of dynamic blocks. For instance, how can I retrieve and modify parameter values within a dynamic block that has a specific block identifier? I would appreciate any code examples or methods you could share.
Additionally, I want to interact with parameters and actions within dynamic blocks. What steps should I take to automatically change a parameter value or trigger a specific action within a block? Any best practices or coding approaches you could recommend would be very helpful.
Another area I’m looking into is filtering and selecting dynamic blocks based on specific attributes or parameter values. How can I create a Visual LISP routine to select blocks that meet certain criteria? I’m interested in methods and code examples that can help with this task.
If anyone has encountered similar issues, feel free to reach out to me on Twitter for quicker assistance. ultrabet
Lastly, I'm facing performance issues when working with a large number of dynamic blocks. I’d like to know how I can optimize my Visual LISP code to perform better, especially with large-scale drawings. Any suggestions for performance improvements and best practices would be greatly appreciated.
If you have experience with the above topics, or if you can provide code samples or general advice, I would be very grateful. I’m looking for practical solutions and approaches that you’ve found effective in handling these issues.
Thank you in advance for your help!
Best regards
A good place to start would be learning how to use Lee Macs already created dynamic block functions
Agree, Lee-mac dynamic block is the way to go, you can use it and add front ends via lisp, for me display in a dcl say the visibility states, in a dcl display multiple properties eg distance1, distance2.
Re get information, the dynamic blocks end up as block names *U23 *U24 etc an anonymous name, but you can get the "Effectivename" of a block the original name, so you can say count up dynamic block properties.
Anyway here is some insert a dynamic block and choose visibilty state. Save the multi radio buttons.lsp and Lee's functions to a support path so it will auto load. I saved the Lee-mac dynamic block functions to a lisp file called "Lee-mac Dynamic block get-put.lsp" you can save to a different file name just change code to suit.
; Change dynamic block properties when inserting look at properties available.
; By Alan H June 2022
;; Get Dynamic Block Property Allowed Values - Lee Mac
;; Returns the allowed values for a specific Dynamic Block property.
;; Set Dynamic Block Visibility State - Lee Mac
;; Sets the Visibility Parameter of a Dynamic Block (if present) to a specific value (if allowed)
;; Get Visibility Parameter Name - Lee Mac
;; Returns the name of the Visibility Parameter of a Dynamic Block (if present)
(defun insdynv (blkname / pt obj lst ans)
(if (not LM:setdynpropvalue )(load "Lee-mac Dynamic block get-put"))
(setq pt (getpoint "\nPick a pt for block "))
(command "-insert" blkname "s" 1.0 pt 0)
(setq obj (vlax-ename->vla-object (entlast)))
(setq visval (LM:getvisibilityparametername obj))
(setq lst (LM:getdynpropallowedvalues obj visval))
(setq lst (cons "Please choose" lst))
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (not AHbut)(setq AHbut 1))
(setq ans (ah:butts 1 "v" lst))
(LM:SetVisibilityState obj ans)
(princ)
)
; set existing block visibilty
(defun insdyne (blkname / pt obj lst ans)
(if (not LM:setdynpropvalue )(load "Lee-mac Dynamic block get-put"))
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(setq obj (vlax-ename->vla-object (car (entsel "\nPick a dynamic block "))))
(setq visval (LM:getvisibilityparametername obj))
(setq lst (LM:getdynpropallowedvalues obj visval))
(setq lst (cons "Please choose" lst))
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (not AHbut)(setq AHbut 1))
(setq ans (ah:butts 1 "v" lst))
(LM:SetVisibilityState obj ans)
(princ)
)
Effective name
(setq ss (ssget '((0 . "INSERT"))))
; single attribute in a dynamic block
(setq lst '())
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(if (= (vlax-get obj 'Effectivename) "Your block name")
(progn
(setq atts (vlax-invoke obj 'Getattributes))
(setq att (vlax-get (car atts) 'textstring))
(setq lst (cons att lst))
)
)
)
Can't find what you're looking for? Ask the community or share your knowledge.