Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto Increment Numbers

Status
Not open for further replies.

taffcad

Mechanical
May 27, 2004
49
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
 
Replies continue below

Recommended for you

Thanks to an unknown author

(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
 
Here is another one. It inserts a number with a circle around it, and increments the number by one. The circle is a block called IDCircle.dwg. Make it the size you want and include a single text attribute cneter justified inside the circle. The LISP is so simple, you should be able to change the start or increment easily.

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

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
 
Copy/paste the code into notepad. Save as put_nums.lsp. Make sure this file is in your support path (ie c:\program files\autocad 2006\support). Then load the lisp file in one of three ways:

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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor