My lisp stalls out, will only complete if I hit enter key a number of times.

My lisp stalls out, will only complete if I hit enter key a number of times.

SKEMPP
Participant Participant
947 Views
6 Replies
Message 1 of 7

My lisp stalls out, will only complete if I hit enter key a number of times.

SKEMPP
Participant
Participant

I can't figure out what is wrong, the lisp runs if I hit the enter key the same number of times that there are tables selected.

The lisp goes through a selection of tables and sets each cell to unlocked. It will be part of a bigger lisp eventually.

(defun C:Unlock_Table_Cells (/)
  (vl-load-com)
  (princ
    "\n*** Select Table's to Unlock ***"
  ) ;_ end of princ
  (if
    (setq ss (ssget
        (list '(0 . "ACAD_TABLE")
        ) ;_ end of list
      ) ;_ end of ssget
    ) ;_ end of setq
     ;THEN do this
     (SETQ LEN  (SSLENGTH SS)
    COUNT 0
     ) ;_ end of SETQ
     ;ELSE do this
  ) ;_ end of if
  (WHILE (< COUNT (- LEN 1))
  ;;(WHILE (< COUNT LEN)
     ;(PRINC COUNT)
    (SETQ TblEntityName
   (ssname SS COUNT)
   TblObj
   (vlax-ename->vla-object TblEntityName)
    ) ;_ end of SETQ
   ; (progn
      (setq nRows (- (vla-get-rows TblObj) 1))
      (setq nCols (- (vla-get-columns TblObj) 1))
      (setq row 1)
      (setq cell 0)
      (grread)
      (vla-put-RegenerateTableSuppressed TblObj :vlax-true)
      (while (<= row nRows)
 (while (<= cell nCols)
   (vla-setcellstate TblObj row Cell 0)
   (setq cell (1+ cell))
     ;(princ (strcat "\nRow : " (itoa row) " , cell " (itoa cell))
     😉 ;_ end of princ
 ) ;_ end of while
 (setq row (1+ row))
 (setq cell 0)
      ) ;_ end of while
      (vla-put-RegenerateTableSuppressed TblObj :vlax-false)
      (SETQ COUNT (+ 1 COUNT))
   ; ) ;_ end of progn
  ) ;_ end of WHILE
) ;_ end of defun
(princ)
0 Likes
Accepted solutions (2)
948 Views
6 Replies
Replies (6)
Message 2 of 7

dlanorh
Advisor
Advisor
Accepted solution
Try commenting out the (grread) line

I am not one of the robots you're looking for

Message 3 of 7

SKEMPP
Participant
Participant

Thankyou, That works.

 

Steve

0 Likes
Message 4 of 7

cadffm
Consultant
Consultant

Just for my information: You erased the grread.

New drawing, new table, one cell set to locked, copy this table two times and start your tool.

Check this cell in all three tables, are all unlocked?

In my previous test not! But no time to looking for the issue.

 

Thx in advance for your answer.

 

Sebastian

0 Likes
Message 5 of 7

SKEMPP
Participant
Participant

Yes, you are right. Its still broken.

 

Steve

0 Likes
Message 6 of 7

cadffm
Consultant
Consultant
Accepted solution

.

You should re-think about this:

 

 

 (WHILE (< COUNT (- LEN 1)) <- current
  ;;(WHILE (< COUNT LEN)       <- meaningful

      (SETQ COUNT (+ 1 COUNT))

)

Sebastian

Message 7 of 7

SKEMPP
Participant
Participant

Thank you, You are absolutely correct.

 

Steve

0 Likes