Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Eng-Tips
*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

taffcad (Mechanical) (OP)
31 Oct 05 7:42
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
lpseifert (Civil/Environmental)
31 Oct 05 10:28
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
IFRs (Petroleum)
31 Oct 05 21:32
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)
)
taffcad (Mechanical) (OP)
1 Nov 05 2:29
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
lpseifert (Civil/Environmental)
1 Nov 05 7:24
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.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close