Rename all styles - command line

Rename all styles - command line

dbaldzhiev
Contributor Contributor
1,255 Views
2 Replies
Message 1 of 3

Rename all styles - command line

dbaldzhiev
Contributor
Contributor

I am looking for a way to prefix all text styles in a drawing with the name of the drawing using a script that runs on accoreconsole. Does the RENAME command take only exact matches - I cannot rename all with it from the command line.

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

pendean
Community Legend
Community Legend
Give us an example of what you are trying to achieve... .
0 Likes
Message 3 of 3

Kent1Cooper
Consultant
Consultant
Accepted solution

@dbaldzhiev wrote:

I am looking for a way to prefix all text styles in a drawing with the name of the drawing using a script that runs on accoreconsole. Does the RENAME command take only exact matches - I cannot rename all with it from the command line.


RENAME in the dialog box, but apparently not  in the command-line version, accepts wildcards.  [But it's risky -- if I put in * for the old name, and TEST* for the new, it manages somehow to rename even the Standard Style -- which you're not  supposed to be able to Rename -- as TESTStandard.]

 

Here's an AutoLisp approach that seems to work in minimal testing:

(defun C:SPDN (/ s-entry s-name s-data); = Style Prefixed with Drawing Name
  (while (setq s-entry (tblnext "style" (not s-entry)))
    (setq
      s-name (cdr (assoc 2 s-entry))
      s-data (entget (tblobjname "style" s-name))
    ); setq
    (if (/= s-name "Standard"); leave that one alone
      (entmod
        (subst
          (cons 2 (strcat (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 4)) s-name))
          (assoc 2 s-data)
          s-data
        ); subst
      ); entmod
    ); if
  ); while
  (princ)
); defun

I haven't worked with ACCORECONSOLE, but I assume you could have that Load such a routine from a .lsp file and then run it.

 

Kent Cooper, AIA
0 Likes