Attribute continuous sequential numbering

Attribute continuous sequential numbering

Anonymous
Not applicable
4,639 Views
7 Replies
Message 1 of 8

Attribute continuous sequential numbering

Anonymous
Not applicable

I need a lisp that can make sequential numbering for attributes as follow:

 

1 - allows me to input a prefix and replace the existing text in the attribute or the lisp will not alter the existing text in the attribute, instead it will only attach the number beside the existing text.

Example, I have existing text "D0", the sequence will become D01, D02,... and so on. or It will remove the existing "D0" but will provide me an option to input a prefix D0 before the sequence value.

2 - It allows me to choose the value to begin the sequence with, so that I can continue the sequence from the last value where I stopped.

 

I need this lisp in tagging Door numbers in our current project.. I have 400 doors to put door tags, from D01 - D0400. 

D0 - Doors in Ground floor. D01 means door number 1 in the Ground floor...

D1 - Doors in First floor. D150 means door number 50 in the first floor.

 

Any help will be appreciated, Thank you very much... 😃

 

 

0 Likes
Accepted solutions (2)
4,640 Views
7 Replies
Replies (7)
Message 2 of 8

_gile
Consultant
Consultant

Hi,

 

This is not LISP, but the Increment plugin does what you need and much more...



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 8

dbhunia
Advisor
Advisor
Accepted solution

Hi

 

Try this.......

 

While you want to change the value of "Attribute"...... it must be a Block with Tag, so you have to enter that as a input for once....... As per your requirement I take the increment value as 1.......Otherwise change it here (highlighted in blue) "(setq Inc_Num (+ Inc_Num 1))" as your requirement 

 

(defun C:Ch_Att_Val (/ Inc_Num B_Name Att_Name Pre)
(vl-load-com)
(setq B_Name (getstring "\nInput Block Name: "))
(setq Att_Name (getstring "\nInput Tag Name: "))
(setq Pre (getstring "\nInput Prefix: "))
(setq Inc_Num (getint "\nInput Starting Number: "))
(while (setq pnt (getpoint "\nSpecify Insertion Point: "))
(progn
(setq New_Inp (strcat Pre (rtos Inc_Num 2 0)))
(vl-cmdf "._-insert" B_Name pnt "" "" "")
(setq BLK (entget (entlast)))
(setq Data (cdr (assoc -1 BLK)))
(setq obj (vlax-ename->vla-object Data))
(foreach att (vlax-invoke Obj 'GetAttributes)
(if (= (vla-get-Tagstring att) Att_Name)
(vla-put-Textstring att New_Inp)
);if
);foreach
(setq Inc_Num (+ Inc_Num 1))
);progn
)
(princ)
)

 

 

 

Sorry I get confused with your requirement so I post this................


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 4 of 8

dbhunia
Advisor
Advisor
Accepted solution

Hi

 

Try this.......

 

While you want to change the value of "Attribute"...... it must be a Block with Tag (may be multiple Tag), so you have to enter the Tag Name (its case sensitive) and to choose the Numeric value to begin the sequence as input for once.......then you have to select repeatedly the Attributes/Blocks which you want to change the values......

As per your requirement I take the increment value as 1.......Otherwise change it here (highlighted in blue) "(setq Inc_Num (+ Inc_Num 1))" as your requirement.

 

 

(defun C:Ch_Att_Val (/ Inc_Num Att_Name Pre)
(vl-load-com)
(setq Att_Name (getstring "\nInput Tag Name: "))
(setq Inc_Num (getint "\nInput Starting Number: "))
(while (setq BLK (entget (car(entsel "\nSelect Attribute/Block: "))))
(progn
(setq Data (cdr (assoc -1 BLK)))
(setq obj (vlax-ename->vla-object Data))
(foreach att (vlax-invoke Obj 'GetAttributes)
(if (= (vla-get-Tagstring att) Att_Name)
(progn
(setq Pre (vla-get-Textstring att))
(setq New_Inp (strcat Pre (rtos Inc_Num 2 0)))
(vla-put-Textstring att New_Inp)
)
);if
);foreach
(setq Inc_Num (+ Inc_Num 1))
);progn
)
(princ)
)

 

 

 

(It has been tested in "AutoCAD 2007", hope fully it will work in latest version.)


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 5 of 8

Anonymous
Not applicable

I have attached a Lee Mac lisp that I found somewhere along the way for this specific thing. I use the replace function within the lisp that allows me to select the attribute that I want to replace. The way I use it is to have "#" in the prefix spot, and the number to start with in the middle spot. This will change the attributes to "#1, #2, #3...etc." This is a very good tool, and with a little practice can be used for many different things within cad, from numbering to a find and replace type function.

Message 6 of 8

Anonymous
Not applicable

It works. Thank you very much. 

0 Likes
Message 7 of 8

Anonymous
Not applicable

Thanks for this. I think this is useful but @dbhunia's lisp is just what I've been looking for. 

I will save this for future need. 😃

0 Likes
Message 8 of 8

Anonymous
Not applicable

Hi,

 

How can we use this tool?

0 Likes