Jump to content

Auto Numbering?


AQucsaiJr

Recommended Posts

I have the need of a way to create a string of text in a number sequence. I am working with Termination Racks that have, on average, 42 points. The term racks are numbered vertically 1-42. The number very however... i.e. the term rack could be numbered 1-42, 43-84 and so on... There are 42 points to be assigned numbers and as long as the list can be populated vertically or horizontally, it will work for me. I have attached an image of what a topical term rack looks like... The number sequence on this one is declining from top to bottem, but I ussually make them asend from top to bottem.

42ptermrack.jpg

Link to comment
Share on other sites

  • Replies 126
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    43

  • AQucsaiJr

    34

  • fuqua

    19

  • tony barretto

    5

Top Posters In This Topic

Posted Images

Here's an old one I wrote, could be modified to "auto-number".

 

;; ============ Num.lsp ===============
;;
;;  FUNCTION:
;;  Will sequentially place numerical
;;  text upon mouse click, with optional
;;  prefix and suffix.
;;
;;  SYNTAX: num
;;
;;  AUTHOR:
;;  Copyright (c) 2009, Lee McDonnell
;;  (Contact Lee Mac, CADTutor.net)
;;
;;  PLATFORMS:
;;  No Restrictions,
;;  only tested in ACAD 2004.
;;
;;  VERSION:
;;  1.0  ~  05.04.2009
;;
;; ====================================


(defun c:num  (/ vlst ovar dVars tmpVars pt)
 (setq    vlst '("OSMODE" "CLAYER")
   ovar (mapcar 'getvar vlst))
 (setvar "OSMODE" 0)
 (or (tblsearch "LAYER" "NumText")
     (vla-put-color
   (vla-add
     (vla-get-layers
       (vla-get-ActiveDocument
         (vlax-get-acad-object))) "NumText") acYellow))
 (setq dVars '(sNum inNum Pref Suff))
 (mapcar '(lambda (x y) (or (boundp x) (set x y))) dVars '(1 1 "" ""))
 (setq tmpVars (list (getreal (strcat "\nSpecify Starting Number <" (rtos sNum 2 2) ">: "))
             (getreal (strcat "\nSpecify Increment <" (rtos inNum 2 2) ">: "))
             (getstring (strcat "\nSpecify Prefix <" (if (eq "" Pref) "-None-" Pref) ">: "))
             (getstring (strcat "\nSpecify Suffix <" (if (eq "" Suff) "-None-" Suff) ">: "))))
 (mapcar '(lambda (x y) (or (or (not x) (eq "" x)) (set y x))) tmpVars dVars)
 (while (setq pt (getpoint "\nClick for Text... "))
   (Make_Text pt (strcat Pref (rtos sNum 2 2) Suff))
   (setq sNum (+ sNum inNum)))
 (mapcar 'setvar vlst ovar)
 (princ))

(defun Make_Text  (txt_pt txt_val)
 (entmake (list '(0 . "TEXT")
        '(8 . "NumText")
        (cons 10 txt_pt)
        (cons 40 (max 2.5 (getvar "TEXTSIZE")))
        (cons 1 txt_val)
        '(50 . 0.0)
        (cons 7 (getvar "TEXTSTYLE"))
        '(71 . 0)
        '(72 . 1)
        '(73 . 2)
        (cons 11 txt_pt))))

Link to comment
Share on other sites

As a quick modification - haven't got time:

 

;; ============ Num.lsp ===============
;;
;;  FUNCTION:
;;  Will sequentially place numerical
;;  text upon mouse click, with optional
;;  prefix and suffix.
;;
;;  SYNTAX: num
;;
;;  AUTHOR:
;;  Copyright (c) 2009, Lee McDonnell
;;  (Contact Lee Mac, CADTutor.net)
;;
;;  PLATFORMS:
;;  No Restrictions,
;;  only tested in ACAD 2010.
;;
;;  VERSION:
;;  1.0  ~  05.04.2009
;;  2.0  ~  15.06.2009
;;
;; ====================================

(defun c:num  (/ dVars tmpVars pt ang sNum*)
 (setq dVars '(sNum eNum inNum Spc Dir))
 (mapcar '(lambda (x y) (or (boundp x) (set x y))) dVars '(1 10 1 1 "X"))
 (setq tmpVars (list (getreal (strcat "\nSpecify Starting Number <" (rtos sNum 2 2) ">: "))
                     (getreal (strcat "\nSpecify Ending Number <" (rtos eNum 2 2) ">: "))
                     (getreal (strcat "\nSpecify Increment <" (rtos inNum 2 2) ">: "))
                     (getreal (strcat "\nSpecify Spacing <" (rtos Spc 2 2) ">: "))))
 (initget "X Y")
 (setq tmpVars
   (append tmpVars (list (getkword (strcat "\nSpecify Direction [X/Y] <" Dir ">: ")))))
 (mapcar '(lambda (x y) (or (not x) (set y x))) tmpVars dVars)
 (if (eq Dir "X") (setq ang 0) (setq ang (/ pi 2)))
 (if (setq pt (getpoint "\nSpecify Start Point: ") i 0 sNum* sNum)
   (while (<= sNum* eNum)
     (Make_Text (polar pt ang (* i Spc)) (rtos sNum* 2 2))
     (setq sNum* (+ sNum* inNum) i (1+ i))))
 (princ))

(defun Make_Text  (pt val)
 (entmake
   (list
     (cons 0 "TEXT")
     (cons 8 (getvar "CLAYER"))
     (cons 10 pt)
     (cons 62 2)
     (cons 40 (getvar "TEXTSIZE"))
     (cons 1 val)
     (cons 50 0.0)
     (cons 7 (getvar "TEXTSTYLE"))
     (cons 71 0)
     (cons 72 1)
     (cons 73 2)
     (cons 11 pt))))

Link to comment
Share on other sites

Oh that is perfect... Thank you... Where can I learn to edit LISP files? I would like to have this also ask for a text style, size, and layer instead of creating a new layer and assuming text style and size.

Link to comment
Share on other sites

I also like the Prefix and sufix in the first code... I guess I should really just learn how to write the code... Thanks for your help!

Link to comment
Share on other sites

May not be the right sub-forum for this but if you are using LT and so can't use lisps try the following two tips-

 

1/

Put the following string on a user defined menu button.

 

*^C^C_text;\;;$M=$(+,$(getvar,USERI1),1);setvar;US ERI1;$M=$(+,$(getvar,USERI1),1);

 

This puts a new text with an incremented value on the drawing with each click of your mouse.

You can also use SETVAR to change USERI1 to 1 below whatever initial value you want.

 

2/

This one increments text that is already on the drawing

 

*^C^C_.Change;\;;;;;;$M=$(getvar,USERI1);_.Setvar; USERI1;$(+,1 ,$(getvar,USERI1))

 

This time though set USERI1 to the value you want to start with.

 

 

I do not take credit for these button macros; I found them some time ago on another website. But they are well worth sharing.

Link to comment
Share on other sites

I can easily modify my LISP to incorporate Prefix/Suffix, and other prompts - just haven't got much time at the moment :wink:

 

You can learn LISP on many sites - AfraLISP, Jeffery Sanders to name a few.

Link to comment
Share on other sites

cool... Well if you do get a lil extra time just let me know... I'll keep this thread in fav to reference it later... If I havn't figured it out by then... I'll look into these places you mentioned... I am interested in writing the LISP's myself as this is not the only one I could use to speed up my drafting process.. I apretiate what you have given me, it is a very good start to what I would lokie to use. Thank you.

Link to comment
Share on other sites

thats a great tool ! but i need some adjusting to it, being a complete lisp noob myself i hope someone can help me.

 

i dont want it to show the nummer behind the dot ie: 123456.00 i just need the first row of numbers without the .00 part. anyone know how i can "demolish" this ?

 

also the text height is 267 (thats waaay to big) can anyone adjust this for me or tell me how ofcourse :)

 

thanx in advance.

Link to comment
Share on other sites

Hey Fuqua,

 

To covert a real number or an integer to a string the function RTOS is used. RTOS takes 3 argument (rtos number mode precision)

 

In your case you need to change the precision.

 

For example

 

(rtos pi 2 2) returns "3.14"

(rtos pi 2 0) returns "3"

 

The part of the code that needs to be updated is

 

  (Make_Text (polar pt ang (* i Spc)) (rtos sNum* 2 2))

Link to comment
Share on other sites

sweet thank you ! that did the trick :D

 

im having 1 more little problem, the justify is on center and left, i just need it to be left. As far as i can see there is no line in the lisp for this, can i add this to it ?

Link to comment
Share on other sites

i have found this tool to change the justification of m and dtext i believe, but it is to much for me, all i need is 1 line to add to the autocounter tool to set the justify at left.

 

;                       ***  JUSTIFY.LSP  ***
;
; Changes the justification of text to:-
;       Left, Center, Right, Aligned, Middle, Fit,
;       Bottom left, center or right,
;       Middle left, center or right, OR
;       Top left, center of right
;
(defun C:JUSTIFY (/ a a1 a2 a3 a4 t m n n1 p1
                   p q j j0 n2 j1 j2 q1 index dummy)
 (setvar "cmdecho" 0)
 (graphscr)
 (prompt "\n *  Select text to change justification...")(terpri)
 (setq t (ssget))
 (if $just
   (setq dummy nil)
   (setq $just "C")
 )
 (prompt "\n *  Enter appropriate letter or select from pull down menu...")
 (initget "L C R A M F BL BC BR ML MC MR TL TC TR")
 (setq j1 (getkword (strcat
   "\n *  L/C/R/M/A/F/BL/BC/BR/ML/MC/MR/TL/TC/TR: <" $just "> ")))
 (if (= j1 "")
   (setq j1 $just)
   (setq $just j1)
 )
 (setq m (sslength t)
       index 0)
 (repeat m
   (setq a (entget (ssname t index))
         p (cdr (assoc 0 a)))
   (if (= p "TEXT")
     (progn
        (setq j (assoc 72 a)
              j2 (assoc 73 a)
              p (assoc 10 a)
              q (assoc 11 a)
              j0 (cdr j))
        (if (or (= j1 "L")(= j1 "C")(= j1 "R")(= j1 "M")
                (= j1 "BL")(= j1 "BC")(= j1 "BR")
                (= j1 "ML")(= j1 "MC")(= j1 "MR")
                (= j1 "TL")(= j1 "TC")(= j1 "TR"))
          (if (= j0 0)
            (progn
              (setq p1 (cdr p)
                    q1 (cons (car q) p1)
                    n1 (subst q1 q a))
            )
            (progn
              (setq q1 (cdr q)
                    p1 (cons (car p) q1)
                    n1 (subst p1 p a))
            )
          )
        )
        (if (or (= j1 "A")(= j1 "F"))
          (progn
            (prompt "\n ")
            (prin1 (+ index 1))
            (setq a1 (getpoint "\nEnter first alignment point...")
                  a2 (getpoint "\nEnter second alignment point...")
                  a3 (cons (car p) a1)
                  a4 (cons (car q) a2)
                  n1 (subst a3 p a)
                  n2 (subst a4 q n1))
          )
        )
        (cond ((= j1 "L")  (setq n (subst '(72 . 0) j n1))
                           (setq n (subst '(73 . 0) j2 n)))
              ((= j1 "C")  (setq n (subst '(72 . 1) j n1))
                           (setq n (subst '(73 . 0) j2 n)))
              ((= j1 "R")  (setq n (subst '(72 . 2) j n1))
                           (setq n (subst '(73 . 0) j2 n)))
              ((= j1 "A")  (setq n (subst '(72 . 3) j n2))
                           (setq n (subst '(73 . 0) j2 n)))
              ((= j1 "M")  (setq n (subst '(72 . 4) j n1))
                           (setq n (subst '(73 . 0) j2 n)))
              ((= j1 "F")  (setq n (subst '(72 . 5) j n2))
                           (setq n (subst '(73 . 0) j2 n)))
              ((= j1 "BL") (setq n (subst '(72 . 0) j n1))
                           (setq n (subst '(73 . 1) j2 n)))
              ((= j1 "BC") (setq n (subst '(72 . 1) j n1))
                           (setq n (subst '(73 . 1) j2 n)))
              ((= j1 "BR") (setq n (subst '(72 . 2) j n1))
                           (setq n (subst '(73 . 1) j2 n)))
              ((= j1 "ML") (setq n (subst '(72 . 0) j n1))
                           (setq n (subst '(73 . 2) j2 n)))
              ((= j1 "MC") (setq n (subst '(72 . 1) j n1))
                           (setq n (subst '(73 . 2) j2 n)))
              ((= j1 "MR") (setq n (subst '(72 . 2) j n1))
                           (setq n (subst '(73 . 2) j2 n)))
              ((= j1 "TL") (setq n (subst '(72 . 0) j n1))
                           (setq n (subst '(73 . 3) j2 n)))
              ((= j1 "TC") (setq n (subst '(72 . 1) j n1))
                           (setq n (subst '(73 . 3) j2 n)))
              ((= j1 "TR") (setq n (subst '(72 . 2) j n1))
                           (setq n (subst '(73 . 3) j2 n)))
        )
        (entmod n)
     )
   )
   (setq index (+ index 1))
 )
 (prin1)
 (princ "    Changed ")                ; Print total lines changed
 (princ index)
 (princ " text lines.")
 (terpri)
 (princ)
)

Link to comment
Share on other sites

nevermind i figured it out myself :)

 

this piece of code gave the justify codes for a positions

 

(cond ((= j1 "L")  (setq n (subst '(72 . 0) j n1))
                           (setq n (subst '(73 . 0) j2 n)))

 

so i looked up in the auto count tool for something similar and found this

 

(cons 7 (getvar "TEXTSTYLE"))
        '(71 . 0)
        '(72 . 1)
        '(73 . 2)

 

i changed this to

(cons 7 (getvar "TEXTSTYLE"))
        '(71 . 0)
        '(72 . 0)
        '(73 . 0)

 

and i got me justify on bottom left :)

 

i hope this piece of info helps others, cheers all.

Link to comment
Share on other sites

I also like the Prefix and sufix in the first code..

readded

(defun c:num  (/ tmpVars pt ang sNum*)
 (setq dVars '(sNum eNum inNum Spc Pref Suff tsize Dir))
 (mapcar '(lambda (x y) (or (boundp x) (set x y))) dVars '(1 10 1 1 "" "" 2.5 "X"))
 (setq tmpVars (list (getreal (strcat "\nSpecify Starting Number <" (rtos sNum 2 0) ">: "))
                     (getreal (strcat "\nSpecify Ending Number <" (rtos eNum 2 0) ">: "))
                     (getreal (strcat "\nSpecify Increment <" (rtos inNum 2 0) ">: "))
                     (getreal (strcat "\nSpecify Spacing <" (rtos Spc 2 2) ">: "))
             (if (=(setq tmppref (getstring (strcat "\nSpecify Prefix <" (if (eq "" Pref) "-None-" Pref) ">: "))) "") Pref tmppref)
                     (if (=(setq tmpsuff (getstring (strcat "\nSpecify Suffix <" (if (eq "" Suff) "-None-" Suff) ">: "))) "") Suff tmpsuff)
             (if (not(setq tmptsize (getreal (strcat "\nSpecify Textsize <" (if (eq nil tsize) "-None-" (rtos tsize)) ">: ")))) tsize tmptsize)
             ))
               
 (initget "X Y")
 (setq tmpVars
   (append tmpVars (list (getkword (strcat "\nSpecify Direction [X/Y] <" Dir ">: ")))))
 (mapcar '(lambda (x y) (or (not x) (set y x))) tmpVars dVars)
 (if (eq Dir "X") (setq ang 0) (setq ang (/ pi 2)))
 (if (setq pt (getpoint "\nSpecify Start Point: ") i 0 sNum* sNum)
   (while (<= sNum* eNum)
     (Make_Text (polar pt ang (* i Spc)) (strcat Pref (rtos sNum* 2 0) Suff) tsize)
     (setq sNum* (+ sNum* inNum) i (1+ i))))
 (princ))

(defun Make_Text (pt val tsize)
 (entmake
   (list
     (cons 0 "TEXT")
     (cons 8 (getvar "CLAYER"))
     (cons 10 pt)
     (cons 62 2)
     (cons 40 tsize)
     (cons 1 val)
     (cons 50 0.0)
     (cons 7 (getvar "TEXTSTYLE"))
     (cons 71 0)
     (cons 72 1)
     (cons 73 2)
     (cons 11 pt))))

and I have added a textsize prompt.

 

Greetings from Austria - Scrimski

Link to comment
Share on other sites

This works great... One question though... What would I type in the prefix and suffix if I want it to be blank?

Link to comment
Share on other sites

Another question.... How would I get the numbers, in the vertical Y form, to go from 1 to whatever, from top to bottom rather than bottom to top, as it is doing now?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...