I would like to rename just a single revision Letter and or option Numbers in the name of multiple blocks
(text string "ZZZ-123-rev.A-object name-option.1-date").
For example, I have 15 blocks in the drawing with names similar to:
and I need to revise to
"C:ren", and change one by one, coz wild cards not working if blocks have different characters among *REV.* and *OPTION.*
Would be awesome if it will work like: - > (lisp...) - > type: *REV.A* rename to *REV.B*, and *OPTION.1* to *OPTION.2* for all blocks in the set.
P.S. all blocks has same naming structure: "A-B-rev.A-<name>-option.1-<date>"
<name> - Table 1 , or Table 34, ...(stays unchanged)
<date> - 2011, or 2013 ... (stays unchanged)
A few questions:
Would you always want to change both the REV.[letter] and the OPTION.[number] in every Block name? Or might you at least sometimes want to change only one or the other?
Would something that automatically just increases the letter and the number by one, regardless of their starting values, without User input, be appropriate? Or would you want the User to specify which letter/number values to change and what to change them to [for instance, if you might sometimes want to change from, say, A to C instead of to B]?
The program "All File Renamer" http://www.altarsoft.com/all_file_renamer.shtml
will rename the portion of any name in all files in this format:
Replace with: REV.2
But this program is for windows explorer only.
If there is a LISP that will run Find and Replace in the Block names, that would be awesome.
Ideas Yes, Need more info though, answer the question at Kent Coopers post, We do not blindly write a program without knowing all the details. (sometimes we do )
Find and replace approach
(defun C:BNM- (/ blist bl b find replace FindList Replacelist NewName) (defun _match (b l) (vl-every '(lambda (k) (wcmatch (strcase b) (strcat "*" k "*"))) l ) ) (setq blist '() bl nil FindList nil Replacelist nil) (while (and (setq find (Strcase (getstring "\nString to Find/Press Enter for none: "))) (not (eq "" find)) (setq FindList (cons find FindList)) (setq replace (Strcase (getstring (strcat "\nReplace " find " with: ")))) (not (eq "" replace)) (setq replaceList (cons replace replaceList)) ) ) (and FindList (while (setq bl (tblnext "block" (not bl))) (and (zerop (logand 53 (cdr (assoc 70 bl)))) (_match (setq bl (cdr (assoc 2 bl))) FindList) (or (member bl blist) (setq blist (cons bl blist))) ) ) blist (foreach itm blist (setq Newname itm) (mapcar '(lambda (x y / p) (setq p (vl-string-search x (strcase itm)) Newname (strcat (strcat (substr Newname 1 p) y (substr Newname (+ p (strlen x) 1)))))) findlist Replacelist) (command "_rename" "_b" itm NewName) ) ) (print (length blist))(princ " Blocks Renamed") (princ) )
This demo will look for REV.A and OPTION.1
String to Find/Press Enter for none: Rev.A
Replace REV.C with: Rev.B
String to Find/Press Enter for none: option.1
Replace OPTION.1 with: Option.2
now if and only if these two items are found on the block name
Only then it will renamed the block with this new values
2 Blocks Renamed
Now if you only need to find 1 "string match" on the block name, This will look for REV.B regardless of option number
String to Find/Press Enter for none: Rev.B
Replace REV.C with: Rev.C
String to Find/Press Enter for none:
3 Blocks Renamed
Another one would be a "Bump" to next value. without prompting for "replace with"
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.