Sample usage:
_$ (getdbval (entlast) "Swing" "Value")
0
_$ (getdbval (entlast) "Jamb" "Value")
5.5
_$ (getdbval (entlast) "Door Width" "Value")
38.0
_$ (getdbval (entlast) "Door Width" "AllowedValues")
(24.0 28.0 30.0 32.0 34.0 36.0 38.0 40.0 42.0 44.0 46.0 48.0)
PHP Code:
(defun getdbval (ent name vname / val-list ent obj v vval sal salnth
count )
(setq obj (vlax-ename->vla-object ent))
(setq v (vla-getdynamicblockproperties obj))
(setq vval (vlax-variant-value v))
(setq sal (vlax-safearray->list vval))
(setq salnth (length sal))
(setq count 0)
(setq val-list nil)
(while (/= count salnth)
(setq val-list
(collect
val-list
(cons
(lisp-value (vlax-get-property (nth count sal)
"PropertyName"))
(lisp-value
(vlax-get-property (nth count sal) vname)))))
(setq count (+ count 1)))
(cdr (assoc name val-list))) ; returns propery name's value of 'vname'
(defun lisp-value (v)
(cond
((= (type v) 'variant) (lisp-value (variant-value v)))
((= (type v) 'safearray) (mapcar 'lisp-value (safearray-value v)))
(t v)))
(defun collect (old-list new-element / new-list)
(setq new-element (list new-element))
(if old-list
(setq new-list (append old-list new-element))
(setq new-list new-element))
new-list) ;defun