check if parameter exist - if not move on (ispropertyvalid)
Hi.
I need to check if a parameter exist in a block.
I use this code:
if the parameter exist all is well and the lisp works,
But if it doesn't exist, the lisp throws an error instead of taking the "IF" result as false and moving on.
I have done countless searches on the issue and have not found a solution.
I rely don't know how to solve this issue and I'll be glad for any help.
thanks,
aridzv.
I need to check if a parameter exist in a block.
I use this code:
(if (setq x (getpropertyvalue ent "d1")))
if the parameter exist all is well and the lisp works,
But if it doesn't exist, the lisp throws an error instead of taking the "IF" result as false and moving on.
I have done countless searches on the issue and have not found a solution.
I rely don't know how to solve this issue and I'll be glad for any help.
thanks,
aridzv.
0
Comments
-
Hi,
I got this from an old script (get the whole list of parameters and check) :
(setq instHandle (BmLispGet "Instance" ent))
(setq instName (BmLispGet "InstanceName" instHandle))
(setq compHandle (BmLispGet "Component" instHandle))
(setq paramList (BmLispGet "Parameters" compHandle))
(foreach p paramList
(setq parexp (BmLispGet "ParameterExpression" compHandle p))
(setq val (BmLispGet "ParameterValue" compHandle p))
(if (= p "Width") (setq WxH (rtos val)))
(if (= p "Height") (setq WxH (strcat WxH "x" (rtos val))))
(if (= p "W") (setq WxH (rtos val)))
(if (= p "H") (setq WxH (strcat WxH "x" (rtos val))))
(if (= p "D") (setq WxH (strcat "Ø" (rtos val))))
)0 -
Lee Mac solved it:
(defun c:test ( / ent ) (if (setq ent (car (entsel))) (if (ispropertyvalid ent "d1~MCAD") (print (getpropertyvalue ent "d1~MCAD")) (princ "\nProperty not valid.") ) ) (princ) )
0