Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Nothing selected, Not a dimension loop

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
smaher12
441 Views, 7 Replies

Nothing selected, Not a dimension loop

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.")
   )

7 REPLIES 7
Message 2 of 8
pbejse
in reply to: smaher12

(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

 

Message 3 of 8
smaher12
in reply to: pbejse


@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?
 

Message 4 of 8
pbejse
in reply to: smaher12


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

 

 

 

Message 5 of 8
smaher12
in reply to: pbejse

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

 

Message 6 of 8
pbejse
in reply to: smaher12


@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

 

 

Message 7 of 8
smaher12
in reply to: pbejse

pbejse, it's perfect. Thank you very much.

Message 8 of 8
pbejse
in reply to: smaher12


@smaher12 wrote:

pbejse, it's perfect. Thank you very much.


You are welcome, Happy to help

 

Cheers

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost