working with duplicate styles

Wondering how to accomplish a certain animation task? Ask here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
amanandink
Posts: 259
Joined: Wed Feb 13, 2008 10:28 pm
Location: Kilkenny, Ireland
Contact:

working with duplicate styles

Post by amanandink »

I was wondering if anybody has a way to work with duplicate styles in a file, if you import a model again that is already there, to have a different angle of pose it creates a new set of styles. they are all the same colour but different styles if i want to update something like...

body
body 2
body 2 2

I was just curious if anyone ha found a way to get rid of the duplicates and use just the first list of styles. I do some work with the text version of the asp file to make changes but i'm not sure it will work in this case, short of hand changing them i'm not sure.

thanks
J
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Re: working with duplicate styles

Post by heyvern »

Hand changing with a text editor is what I do when it gets really out of control and too difficult to do in Anime Studio.

What I do is change all of the shapes that are using one of the duplicate styles FIRST, then I open the file in Anime Studio and use the "delete unused styles" command.

================================================
WARNING! ALWAYS WORK ON A COPY OF THE FILE!!!!!
Just in case. Save a copy and make text edit changes
to the copy so you have a backup if anything goes wrong.
================================================


The way to change ONLY the shapes using a style first is to look for multiple "tab" characters in front of the style name with search and replace in a text editor. Styles assigned to shapes always have will always have several tab characters in front of the name you need to change. (shapes are "indented" based on the depth of layers).

The top of the file where the style definitions are placed the style names have NO whitespace in front of the name. Easy to find that way.

Here is an example of one of my files:
This is how the style name is defined usually near the "top" of the file format.

Code: Select all

style
"glasses"
Later in the file, a vector layer with a shape uses this style. This vector layer is inside a bone layer. There are 5 tab characters in front of the quoted name of the style based on its depth in the layer grouping.

Code: Select all

					"glasses"

So for example, lets say a bunch of shapes were using duplicate styles like these:
"glasses 2"
"glasses 2 2"
"glasses 2 2 2"

And I wanted to change ALL of them to a single "glasses" style.
I would do a "search and replace" of those names including multiple tabs at the beginning of that line and then change the name, removing the numbers after the name. I don't replace or change the duplicate styles. Just to be "safe" I prefer removing the unused styles in Anime Studio. The result then would be that all references to the duplicates would now reference the "original" or whatever style I chose to change it to.

You should be careful about searching for style names in shapes. Often the name of a style might be the same as a layer name or possibly a bone name. These other quoted names may get "hit" in the search if the search isn't formatted correctly it will change the wrong thing. I will sometimes change the name of styles in Anime Studio to something very specific to search for and replace just as a precaution and also makes it easy to know exactly what needs to be done.

For example I might change:
"glasses 2 2 2"
to
"glasses 2 2 2 delete style"

However I haven't had to worry too much about this. I find that styles tend to be distinct from layer or bone names. Layer names look like this:

Code: Select all

		name "glasses 3"
No tab in front of the quoted name just the word "name" and a space, so my search for only a leading tab won't hit this layer name.

Bone names are also easy to avoid because they always have stuff AFTER the name.
This is a BONE defined in the same sample file:

Code: Select all

			"glasses" -1 -1 1 -1 1 1 -1 1 false false false 0.236166 0 -1 false
Style names referenced in a shape ALWAYS have a line ender immediately after the quoted name.
Style names are ALWAYS wrapped in quotes with X leading tab characters on a single line.

I use a Mac only application called BBedit to do all of my text editing. It has very powerful regular expression search (regex). There are probably many more application options for Windows with the same powerful features. I save complex searches so I can reuse them, however the search needed for style replacement is so simple I can easily do it from memory:

The following searches work in BBedit but also may work in other applications. Some apps use different codes for special characters like end of line or tab.

Regex search:

Code: Select all

\t"glasses[0-9 ]+"$
The above search would find ANY reference to a "duplicate" style with that name and multiple numbers of any kind after the name. It also only finds the quoted name that has a leading tab and a return or end of line after it.

Replace:

Code: Select all

\t"glasses"
This replaces ALL of the duplicated style name references with ONE style name of my choice. I don't have to do multiple searches for a bunch of duplicates because I am searching for ANY number and space after the name. No worries about hitting layer or bone names by accident because of the regex patterns for the tab and line ender.

Don't forget to remove unused styles after reopening in Anime Studio. This will also tell you if it worked properly. If the duplicates are removed you know it worked and you got them all.

I often have really complex files with lots of imported Anime Studio files that create duplicate style names. I use this text editor replacement a lot. It's really fast and clean and works a treat!

It seems like a lot of steps but in reality it's relatively easy and WAY faster than trying to do this by hand. It's just as fast to change 1000 shapes styles as 1.
amanandink
Posts: 259
Joined: Wed Feb 13, 2008 10:28 pm
Location: Kilkenny, Ireland
Contact:

Re: working with duplicate styles

Post by amanandink »

thanks Vern, this is great. I'm definitely going to work this in to our workflow.
Just as an aside, we have been using TextfindX in much the same way to change characters palettes from day to night, its quite a handy text find and replace tool or Sublime Text 2 for doing group line find/replace to multiple files. Both might be worth having a look at if you haven't seen them already.

thanks again
Jeremy
Post Reply