Increment Text

Increment Text

Anonymous
Not applicable
1,823 Views
3 Replies
Message 1 of 4

Increment Text

Anonymous
Not applicable

Hai all,

 

             please suggest me for the command of text increment in autocad i want to know if i can to continue the number with the alphabet 

(ex:. "A1/ST7/01") if i pick this tag "A1/ST7/01" the next tag must be "A1/ST7/02, A1/ST7/03, A1/ST7/04, A1/ST7/05 ,etc......  this same option is in microstation software. is there any lisp or some thing like that.

0 Likes
Accepted solutions (1)
1,824 Views
3 Replies
Replies (3)
Message 2 of 4

_gile
Consultant
Consultant

Hi,

 

If you're looking for an already "cooked fish" you can get the Increment plugin on Exchange Apps Store.

 

If you want to learn fishing, you should get some inspiration with this:

 

 

    ;; INCSUFF -Gilles Chanteau- 2008/01/15
    ;; Adds the specified increment to a string suffix.
    ;; Is considered as suffix, all [0-9], [A-Z] and [a-z] characters from
    ;; the end of the string according to flag value.
    ;;
    ;; Arguments
    ;; str : a string
    ;; inc : a positive integer
    ;; flag : an integer, the sum of following binary codes
    ;;       1 for numbers [0-9]
    ;;       2 for uppercase  [A-Z]
    ;;       4 for lowercase [a-z]
    ;;
    ;; Return
    ;; The string with incremented suffix (or nil if none valid suffix)
    ;;
    ;; Examples :
    ;; (incsuff "N° 002" 12 1) = "N° 014"
    ;; (incsuff "Drawing_A" 1 1) = "Drawing_B"
    ;; (incsuff "test_ZZ9" 1 3) = "test_AAA0"
    ;; (incsuff "test_ZZ9" 1 1) = "test_ZZ10"
    ;; (incsuff "12-" 1 nil) = nil
    ;;
    ;; Update (13/02/08) : binary codes

    (defun incsuff (str inc flag / lst crt pas ind dep quo ret)
      (setq lst (reverse (vl-string->list str)))
      (while
        (and
          (setq crt (car lst))
          (cond
    	((< 47 crt 58)
    	 (setq pas 10
    	       ind 48
    	 )
    	)
    	((and flag (< 64 crt 91))
    	 (setq pas 26
    	       ind 65
    	 )
    	)
    	((and flag (< 96 crt 123))
    	 (setq pas 26
    	       ind 97
    	 )
    	)
    	((< 0 quo)
    	 (setq crt (if (= 10 pas)
    		     ind
    		     (1- ind)
    		   )
    	       lst (cons (car lst) lst)
    	 )
    	)
          )
        )
         (setq dep (- crt ind)
    	   quo (/ (+ dep inc) pas)
    	   ret (cons (+ ind (rem (+ dep inc) pas)) ret)
         )
         (if (zerop quo)
           (setq ret (append (reverse (cdr lst)) ret)
    	     lst nil
           )
           (if (cdr lst)
    	 (setq lst (cdr lst)
    	       inc quo
    	 )
    	 (setq lst (list ind)
    	       inc (if (= 10 pas)
    		     quo
    		     (1- quo)
    		   )
    	 )
           )
         )
      )
      (if ret
        (vl-list->string ret)
      )
    )

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 4

Anonymous
Not applicable

wht is fun key for this lisp 

actually this one is not working on my computer 

 

0 Likes
Message 4 of 4

_gile
Consultant
Consultant
Accepted solution

The upper LISP code is not an "OOTB LISP defined command", this is a LISP routine (user defined function) to be used the same way as built-in LISP functions (if you want to learn fishing).

You can see using examples in the comments.

 

The purposed plugin on Exchange Apps is an OOTB .NET defined command (command name: GILE_INCR).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes