Jump to content

Getting and setting a user defined parameter of a block using AutoLisp


Recommended Posts

Posted

I have a block that represents a section of a duct. It has custom properties of "Duct_Width". I am trying to gte the property through lisp using:

 

(vlax-get-property (vlax-ename->vla-object (car (entsel))) "Duct_Width")

 

but I get an error saying "unknown name: Duct_Width". Is it that vlax-get-property does not work on customized parameters? Is there a way I can retrieve "Duct_Width"? And if possible, how to set it? Thank you very much. 

Posted

Sounds like a dynamic block. Post a sample drawing.

Posted
20 hours ago, ronjonp said:

Sounds like a dynamic block. Post a sample drawing.

It is a dynamic block indeed. Please see attached sample duct.

Duct Sample.dwg

Posted
20 hours ago, Lee Mac said:

Try using my Get Dynamic Block Property Value function, e.g.:

 

(LM:getdynpropvalue (vlax-ename->vla-object (car (entsel))) "Duct_Width") 

 

Hi Lee Mac, your function works great,  as well as the set property one, thanks a lot!

Posted
1 hour ago, Reaper_of_Lykos said:

Hi Lee Mac, your function works great,  as well as the set property one, thanks a lot!

 

Great stuff - you're welcome! 👍

Posted

Thanks to you Lee this is insert a block and pop the visibility states in a dcl so can choose rather than go to properties to set.

 

; 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)
)

 

Need multi radio buttons save in a support path location or edit the (load "Multi radio buttons") with correct path.

 

Same with input values would use Multi getvals.lsp with LM:getdynprops

 

Multi radio buttons.lsp

 

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...