I am currently working on a project that requires me layout an area by inserting blocks at certain locations. The block is a generic attributed block but I sumetimes need to have multipe groups of blocks i.e. G001, G002 then H001 and so on. I was just wondering if there is a way for me to select all the blocks in the drawing (using select similar) and then number the blocks automatically in a sequential order but also have an option to append a letter to the front. I have found some lsps around the web that do some of this but it's never quite what I need. Trying to reverse engineer them and apply it to my own lsp is a little above my skill level haha Any help is gratly appreciated.
@Anonymous wrote:
I am currently working on a project that requires me layout an area by inserting blocks at certain locations. The block is a generic attributed block but I sumetimes need to have multipe groups of blocks i.e. G001, G002 then H001 and so on. I was just wondering if there is a way for me to select all the blocks in the drawing (using select similar) and then number the blocks automatically in a sequential order but also have an option to append a letter to the front. I have found some lsps around the web that do some of this but it's never quite what I need. Trying to reverse engineer them and apply it to my own lsp is a little above my skill level haha Any help is gratly appreciated.
Will that be a constant value for the LETTER? Other cases with no LETTER at all?
You wont be able to control the "sequence" if you are planning to use a "Select Similar" method of selection, unless its by order of creation.
Just a thought, you mentioned "certain locations" , is that like in a row/column grid position? is so then yes, select similar would work justfine.
You found a lisp, post it here [plesase do acknowledge the author]. You may havea better chance of "reverse engineering" the code with forum members help.
pBe
EDIT: this may interest you --> To sort the blocks look into this link BlockSSSort.lsp by Kent Cooper <-- post # 9
You can also try ALTEXT.vlx which is able to numbering block attributes in a sequence and add prefix at the same time.
Hello....
I have written a lisp routine which increments attribute values sequentially.I attaching the same with this message.
Hope this will serve your purpose.
Command for using this : incr
Here is the existing script I use but it requires clicking each individual block, I need to be able to select all blocks at once.
(defun c:NUMME (/ oldPref oldSuf oldStart curText curStr
numZeros)
(vl-load-com)
(initget 6)
(setq numZeros (getInt "\nEnter number of 0 prefix's:"))
(defun num2str (num / numStr)
(setq numStr (itoa num))
(If (< (strlen numStr) numZeros)
(repeat (- numZeros (strlen numStr))
(setq numStr (strcat "0" numStr))
)
)
numStr
)
(if(not rnm:Pref)(setq rnm:Pref ""))
(if(not rnm:Suf)(setq rnm:Suf ""))
(if(not rnm:Start)(setq rnm:Start 1))
(setq oldPref rnm:Pref
oldSuf rnm:Suf
oldStart rnm:Start); end setq
(setq rnm:Pref
(getstring T
(strcat "\nPrefix: <"rnm:Pref">: ")))
(if(= "" rnm:Pref)(setq rnm:Pref oldPref))
(if(= " " rnm:Pref)(setq rnm:Pref ""))
(setq rnm:Suf
(getstring T
(strcat "\nSuffix: <"rnm:Suf">: ")))
(if(= "" rnm:Suf)(setq rnm:Suf oldSuf))
(if(= " " rnm:Suf)(setq rnm:Suf ""))
(setq rnm:Start
(getint
(strcat "\nStarting number <"
(itoa rnm:Start)">: ")))
(if(null rnm:Start)(setq rnm:Start oldStart))
(while T
(setq curStr(strcat rnm:Pref(num2Str rnm:Start)rnm:Suf))
(setq curText
(car
(nentsel "\n<<< Pick TEXT, MTEXT or ATTRIBUTE or press Esc to quit >>> ")))
(if
(and
curText
(member(cdr(assoc 0(entget curText))) '("TEXT" "MTEXT" "ATTRIB"))
); end and
(progn
(vla-put-TextString
(vlax-ename->vla-object curText)curStr)
(setq rnm:Start(1+ rnm:Start))
); end progn
(princ "\n This is not DText or MText ")
); end if
); end while
(princ)
); end of c:renum
(princ "\n[Info] http:\\\\www.AsmiTools.com [Info]")
(princ "\n[Info] Renumber tool. Type RENUM to run. [Info]")
@Anonymous wrote:
Here is the existing script I use but it requires clicking each individual block, I need to be able to select all blocks at once.
.....
That is exactly my point HaleOED, You may have a problem with "all blocks at once" appraoch, the sequence will depend on the entity creation order.
Are you fine with that? We can modify the code to select all TEXT,MTEXT,ATTRIBUTE all at once just for you to see what happens to the sequence.
And what about attributes? if there are more than 1 attribute definition on the block? say 2 or 3? modify all of them? and what if the items already have the prefix/suffix? Remember i'm talking about selecting ALL at once here.
Better yet, post a dwg sample here.
pBe
EDIT: oops, i forgot, you did mention attribute blocks, so the question about attribute still stands,
We can do this via selection on screen, pick the blocks on the order of sequence then press enter to process the selection. will that work for you?
The blocks only have 1 attribute and your suggested mode for selection would work perfectly. The numbering could be based on the entity order creation no problem. Apologies for not being clearer.
PLEASE TRY THIS CODE...WHICH I HAVE MODIFIED AS PER YOUR REQUIREMENT
USAGE: COMMAND IS "INCR"....THEN ENTER STARTING NUMBER OF THE SEQUENCE AND THE SELECT THE BLOCKS WHICH U WANT TO MODIFY AT ONCE....
Thank you, this is close but I need to be able to have a prefix that user inputs i.e. 'G' and I also need the numbers to have two leading zeroes i.e. 009 but then changes to 010 etc
Google: 'autolisp pad string with 0s zeros'
for many forms.
etal.
So you want the whole attribute to be changed to the strings like
"G001" "G002"....if user inputs are "G" and "1" and
"H001" "H002"....if user inputs are "H" and "1"?????
IF SO....DAT IS POSSIBLE....PLEASE MAKE IT CLEAR......
I HAVE MODIFIED THE CODE AS WHAT I MENTIONED IN THE PREVIOUS POST....
IF THIS ALSO DOESN'T WORK....I WILL TRY TO MODIFY AS PER YOUR REQUIREMENT.....NO PROBLEM
SAME COMMAND...BUT TWO INPUTS "G" "1"....LIKE THAT
Thank you so much for that. It doesn't quite do what I need because it pads the zeroes incorrectly when you get to a two digit number. For example it should be H010 instead of H0010, I need the zeros to pad the space. I see a link above posted by another user so I think I shall try to work out how to change that in the script you sent me. Really want to learn how to do this stuff. Thanks!
You are welcome. Try to figure it out...If you struck somewhere I can assist you further
@chaitanya.chikkala wrote:You are welcome. Try to figure it out...If you struck somewhere I can assist you further
Hello sir, thank you for this lisp. I am also working with multiple blocks with attributes, I have tried your lisp and it is very close to what i need. please help me modify this lisp a bit that allows user to add another user input suffix at the back and remove the 00. e.g. G1A, G2A, G3A and so on.
TRY THIS OUT WITH THE SAME COMMAND
Sir, It works perfect. This is exactly what I need. thank you very much for your help.
@chaitanya.chikkala wrote:TRY THIS OUT WITH THE SAME COMMAND
Hi, I happen to be in a similar situation however i tried this LISP you posted and it makes sense. The only problem I have is I need to have it assigned to a particular attribute in the block. How can I edit that, I have about 4 attributes?
Thanks.