I'm trying to figure out why the following is not working. Basically if nothing is selected loop. If it is not a dimension loop.
(while
(not
(and
(setq obj (vlax-ename->vla-object (car (entsel "\nSelect a dimension: "))))
(vlax-property-available-p obj 'ArrowHead1Type)
)
)
(princ "\nNothing selected, Not a dimension.")
)
Solved! Go to Solution.
Solved by pbejse. Go to Solution.
(while (not (and (setq obj (car (entsel "\nSelect a dimension: "))) (setq obj (vlax-ename->vla-object obj)) (vlax-property-available-p obj 'ArrowHead1Type) ) ) (princ "\nNothing selected, Not a dimension.") )
HTH
@pbejse wrote:(while (not (and (setq obj (car (entsel "\nSelect a dimension: "))) (setq obj (vlax-ename->vla-object obj)) (vlax-property-available-p obj 'ArrowHead1Type) ) ) (princ "\nNothing selected, Not a dimension.") )HTH
I was sooo close. Thank you very much. Let me ask you this. If I want exit the loop when I hit enter do I need play around with the "errno" variable?
smaher12 wrote:....I was sooo close. Thank you very much. Let me ask you this. If I want exit the loop when I hit enter do I need play around with the "errno" variable?
Yup,
(not (while (progn (setvar 'errno 0) (setq obj (car (entsel "\nSelect a dimension: "))) (cond ((= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ((eq 'ename (type obj)) (if (not (vlax-property-available-p (setq obj (vlax-ename->vla-object obj)) 'ArrowHead1Type ) ) (princ "\nInvalid Object Selected.") ) ) ) ) ) )
HTH
Very nice! Now if I hit enter to exit I get the following above the command line ; error: bad argument type: VLA-OBJECT nil. Do I have something in the wrong location?
(defun c:tmp () (vl-load-com) (not (while (progn (setvar 'errno 0) (setq obj (car (entsel "\nSelect a dimension: "))) (cond ((= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ((eq 'ename (type obj)) (if (not (vlax-property-available-p (setq obj (vlax-ename->vla-object obj)) 'ArrowHead1Type ) ) (princ "\nInvalid Object Selected.") ) ) ) ) ) ) (vlax-put-property obj 'ArrowHeadSize 0.125) (vlax-put-property obj 'ArrowHead1Type 0) (vlax-put-property obj 'ArrowHead2Type 0) (princ) )
@smaher12 wrote:Do I have something in the wrong location?
Yes.
(defun c:tmp () (vl-load-com) (not (while (progn (setvar 'errno 0) (setq obj (car (entsel "\nSelect a dimension: "))) (cond ((= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ((eq 'ename (type obj)) (if (not (vlax-property-available-p (setq obj (vlax-ename->vla-object obj)) 'ArrowHead1Type ) ) (princ "\nInvalid Object Selected.") (progn (vlax-put-property obj 'ArrowHeadSize 0.125) (vlax-put-property obj 'ArrowHead1Type 0) (vlax-put-property obj 'ArrowHead2Type 0) (princ "\nDimension updated:") ) ) ) ) ) ) ) (princ) )
Use those lines as "ELSE"
HTH