Hi,
I tried your code, but the same issue appears :
Command: !var1
101.0
If you want me to be more specific, here I go: I will write a code which will create shapes and single line texts depending on three inputs by the user and by the values contained in a table.
(defun c:TEST (/ c ctr dat etdata ind lst prefix r tab tblent tblobj val varname NbInputs Title NumMod iteration YValue)
(setq snapMode (getvar "osmode")) ;Remove Object Snap (F3)
(setvar "osmode" 0)
(setq NbInputs (getint "\nNumber of inputs: ")) ;Enter Number of inputs
(if NbInputs
(prompt (strcat "\nYou entered: " (itoa NbInputs)))
(prompt "\nYou didn't entered a number."))
(setq NumMod (getint "\nModule Number (ex.: 1): ")) ;Enter module number
(if NumMod
(prompt (strcat "\nYou entered: " (itoa NumMod)))
(prompt "\nYou didn't entered a number."))
(setq Title (getstring "\nTitle (ex.: Title 1): ")) ;Enter Title
(vl-load-com) ;Puts into variables the cells of the table
(setq etdata (entget (setq tblent (car (entsel "\nSelect table object: "))))
ind (cdr (assoc 91 etdata))
tab (cdr (assoc 92 etdata))
r 0
c 0
ctr 1
prefix "var"
tblobj (vlax-ename->vla-object tblent))
(while (< c tab)
(while (< r ind)
(set (setq varname (read (strcat prefix (itoa ctr))))
(progn (setq val (vlax-invoke tblobj 'getcellvalue r c)
val (if (= 'str (type val))
(substr val (- (1+ (strlen val)) (vl-position (ascii ";") (reverse (vl-string->list val)))))
val))))
(setq lst (cons (setq dat (cons varname val)) lst))
(setq ctr (if (listp (cdr dat))
ctr
(1+ ctr))
r (1+ r)))
(setq r 0
c (1+ c)))
(vl-remove-if '(lambda (x) (listp (cdr x))) (reverse lst))
(command "line" "0,-16" "40,-16" "") ;Draw top line
(setq iteration 1) ;Draw circles
(setq YValue -35.25)
(while (<= iteration NbInputs)
(command "circle" (strcat "6.25," (itoa YValue)) "6.25")
(setq YValue (+ Yvalue -30.5))
(setq iteration (1+ iteration)))
(command "_text" "14.5,-37.25" "4" "0" var1 "") ;Create single line texts
(command "_text" "14.5,-67.25" "4" "0" var2 "")
(command "_text" "14.5,-97.25" "4" "0" var18 "")
(command "_text" "14.5,-127.25" "4" "0" var19 "")
(command "_text" "14.5,-157.25" "4" "0" var33 "")
(command "_text" "14.5,-187.25" "4" "0" var34 "")
) ;End of program
Right now I am having issues with the while loop for the circles (see above) and with the zeros following numbers (see picture one or two post above).
I think maybe the problem with the zeros comes because of some kind of Excel formatting. I'll try to change formatting and see what it does.
Thanks