PDA

View Full Version : Obtaining a Dynamic property for text use.


ReachAndre
2009-08-13, 07:18 PM
Hello all,
I am trying to obtain the ductw,ducth and visibilty properties of the attached block. I am then trying to set them to values so that I may use them later in lisp.

I dont know how to get the properties, so the code below, I just left some "Fill in the Blank" type spaces


(defun c:dpropget (/ selblock ductw ducth vs)
(setq selblock (entsel))
(setq vs ());obtain visibility state from selblock)
(setq ductw ());obtain DuctW value from selblock)
(setq ducth ());obtain DuctH value from selblock)
(princ (strcat "\n" (rtos ductw 2 0) " x " (rtos ducth 2 0) " " vs " duct"))
(princ))


and of course, I am not using this lisp just to display information in the command line, I am just doing this for verification of information and display

Thank you all for your help,
Andre

Lions60
2009-08-13, 09:47 PM
This will get you the values of the dynamic block properties. There is a variable called result that is a list of all properties and their values of that dynamic block.


(defun C:getprop(/ props)
(if (setq ent (entsel "\n Select dynamic block >>"))
(progn
(setq obj (vlax-ename->vla-object (car ent)))
))
(dprop obj)
)

(defun dprop (obj / )
(if (equal :vlax-true (vla-get-isdynamicblock obj))
(progn
(setq props (vlax-safearray->list
(variant-value
(vla-getdynamicblockproperties obj))))
(setq result
(mapcar (function (lambda (x)
(cons (vlax-get x 'Propertyname)
(vlax-get X 'Value))))
props)
)
)
)

(foreach a props
(if(eq "Visibility" (vla-get-propertyname a))(setq vis (vlax-get a 'Value)))
(if(eq "DuctW" (vla-get-propertyname a))(setq DuctW (vlax-get a 'Value)))
(if(eq "DuctH" (vla-get-propertyname a))(setq DuctH (vlax-get a 'Value)))
)
)

andrea.andreetti
2009-08-14, 03:49 AM
Hi Andre..

maybe This (http://www.ductisoft.com/en/sduct.html) can be useful for u..