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

Continue code after while-loop

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
jonas_eek_erikson
296 Views, 3 Replies

Continue code after while-loop

I have the following code where after creating a new layer, I loop a function where the user selects an object that get a boundingbox and some property-changes.
 
What I would like after the user is done selecting objects, is to execute two commands . But when pressing spacebar I get an error message "error: bad argument type: lentityp nil".
 
 
 
(defun C:REVN ( / ss blockID point1 point2 newRevLayer rev rRev obj *error*)
      
(vl-load-com)
 
(setq ss (ssget "_X" '((2 . "BL-H-H1"))))
(setq blockID (ssname ss 0))
(setq rRev (getpropertyvalue blockID "REV"))
(setq rev (vl-string-trim " " rRev))
(setq newRevLayer (strcat "REVMARK"rev))
 
(command "._layer" "_make" newRevLayer "_color" 7 "" "")
 
(while
(setq obj (vlax-ename->vla-object (car (entsel))))
(vla-getboundingbox obj 'point1 'point2)
(setq point1 (vlax-safearray->list point1))
(setq point2 (vlax-safearray->list point2))
(setq point1 (list (car point1) (cadr point1)))
(setq point2 (list (car point2) (cadr point2)))
(command "._rectang" point1 point2 "")
(command "._pedit" "_last" "w" 2 "")
(command "chprop" "_last" "" "c" 50 "tr" 40 "")
)
 
(command "._IsdInsertn" "IN-RIVNING")
(while (> (getvar 'CmdActive) 0) (command pause))
(command "._layer" "_set" 0 "")
  )
3 REPLIES 3
Message 2 of 4

The error occurs when you press space bar and there is no entity selected but your code still wants to process as there is

(setq obj (vlax-ename->vla-object (car (entsel))))

so perhaps separate it like this

(while (setq en (entsel)) 
(setq obj (vlax-ename->vla-object (car en)))

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 4

Thank you Paul!
Message 4 of 4

You are welcome…cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report