Auto Increment Numbers
Auto Increment Numbers
(OP)
Hi to all you experts
This is two questions with a related theme. If you have to add numbers say 1-200 to the drawing is there a way of automatically increasing by 1 everytime you add the text. These would be random position on the drawing.
The second part is, if it is possible could that be used to increase increment auto with an array in a line with a fixed dimension between numbers. Would a lisp be able to achieve this type of thing.
Look forward to any replies
Cadman
This is two questions with a related theme. If you have to add numbers say 1-200 to the drawing is there a way of automatically increasing by 1 everytime you add the text. These would be random position on the drawing.
The second part is, if it is possible could that be used to increase increment auto with an array in a line with a fixed dimension between numbers. Would a lisp be able to achieve this type of thing.
Look forward to any replies
Cadman





RE: Auto Increment Numbers
(defun c:put_nums (
/ oldecho tmp numHt numValStr
)
(setq oldecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(if (not numVal) (setq numVal 1))
(if (not numInc) (setq numInc 1))
(setq tmp (getint (strcat "\nStarting number <" (itoa numVal) ">: ")))
(if tmp (setq numVal tmp))
(setq tmp (getint (strcat "\nIncrement by <" (itoa numInc) ">: ")))
(if tmp (setq numInc tmp))
(if (= 0.0 (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))))
(progn
(initget (+ 1 2))
(setq numHt (getdist "\nText height: "))
)
)
(while (setq pikPnt (getpoint
(strcat
"\nInsertion point for "
(itoa numVal)
": "
)
)
)
(setq
numValStr (itoa numVal)
numVal (+ numVal numInc)
)
(command "._text" "mc" pikPnt)
(if numHt (command numHt))
(command "" numValStr)
)
(setvar "cmdecho" oldecho)
(princ)
)
(defun C:PUT_NUMS2 ( / oldecho tmp numHt numValStr)
(setq oldecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(if (not numVal) (setq numVal 1))
(if (not numInc) (setq numInc 1))
(setq tmp (getint (strcat "\nStarting number <" (itoa numVal) ">: ")))
(if tmp (setq numVal tmp))
(setq numValStr (itoa numVal))
(setq tmp (getint (strcat "\nIncrement by <" (itoa numInc) ">: ")))
(if tmp (setq numInc tmp))
(if (= 0.0 (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))))
(progn
(initget (+ 1 2))
(setq numHt (getdist "\nText height: "))
)
);end if
(while (setq pikPnt (getpoint (strcat "\nInsertion point for " numValStr ": ")))
(command "._text" "_mc" pikPnt)
(if numHt (command numHt))
(command "" numValStr)
(setq
numVal (+ numVal numInc)
numValStr (itoa numVal)
)
);end while
(setvar "cmdecho" oldecho)
(princ)
);end C:PUT_NUMS
RE: Auto Increment Numbers
(DEFUN C:NUMB ( / N) ; Insert & increment IDCircle block
(setvar "CMDECHO" 1)
(setq N (getint "\nEnter beginning number <1>: "))
(if (= N nil) (setq N 1))
(while N
(progn
(COMMAND "_INSERT" "IDCIRCLE" "ins" PAUSE "1.0" "1.0" "0" (itoa N) "" )
(setq N (+ 1 N))
)
) ; end while
(princ)
)
RE: Auto Increment Numbers
Great response, many thanks. Now comes the difficult bit. I have never used a lisp routine. So any help will be appreciated. Is it like a block?. Do you find the file and just insert.
Thanks
cadman
RE: Auto Increment Numbers
1. Drag and drop the .lsp file from Windows Explorer directly onto the acad drawing.
2. at the command prompt type (load"put_nums")
3. Tools => Load application
Once the .lsp file is loaded type put_nums at the command prompt to invoke the command.
Lisp only works in full AutoCad. If you have AutoCad LT you're SOL.