In this post, you will find one more script that can make your workflow of making illustrator puppets for Adobe Character Animator * faster and easier. The script attached here will help you automate the process of mirroring right/left character views by swapping the left and right tags in the names of all the elements.
Using this “Swap Left and Right tags” script together with the “remove copy suffix from all layers ” script (posted earlier)Â may help you save hours of tedious work.
The Main Idea
Change all layer names and object names to include the word left instead of right and vice versa.Â
The Problem Explained
For a puppet to work properly in Adobe Character Animator it should follow a very specific hierarchy and naming convention. One of the rules of this naming standard is that the different facial and body elements of the illustrated character should have right and left tags in their names.
Facial features that are named properly are recognized by Adobe Character Animator automatically and save lots of extra rigging work. For example, an right eye should be named as +Right eye. Below it in the hierarchy there should be right blink, +right pupil, right pupil range etc…
So if we copy the left quarter facial view for example and mirror it to turn it into a right quarter facial view, we will need to find all the tagged layers and rename them. It is possible to do it manually, but it may take some time and effort.
The script in this post is created to automate this process. So once you highlight the top layer of the view you want to swap and run the script, all the left tags will turn into right tags and all the right tags will turn into left tags. All in a single click.Â
Who Needs this Script?
- Anyone who wants to speed up the process of illustrating puppets for Adobe Character Animator.
How to Use this Script
- Start with highlighting the top layer containing the layers/objects with the names you want to alter by swapping the words left and right.
- Now navigate to the "swap left and right tags .jsx" script, and run it. (The process of running scripts in Adobe Illustrator is explained in the section below). If you selected a layer containing many nested layers, the process may take a few seconds. You are supposed to see a work in progress window.
- When the job is finished, a pop-up window will appear, stating the number of renamed items.
- Click "Ok" to dismiss it.
You should now have a hierarchy with renamed layers. So If you selected to run the script on the “right profile copy” layer: the layer itself will become the “left profile copy”. All the layers and items containing the word “right” in their name will also change:
- +right ear
- +Right eye
- Right Blink
- Right Pupil with mask
- +Right Pupil
- Right Pupil Range
The above items will now be named:
- +Left ear
- +Left eye
- Left Blink
- Left Pupil with mask
- +Left Pupil
- Left Pupil Range
How to Run Scripts in Adobe Illustrator
There are 2 main ways to run the script in Adobe Illustrator *:
by Going to File --> Scripts --> Other Scripts , and then navigating to where you saved the downloaded .jsx file.
Installing the Script into Script Menu
If you plan to use the script on a regular basis. The best way would be to put the download .jsx file into the Adobe Illustrator/presets/scripts folder. This way you will always have the script accessible in your menus:
Script Logic Explained
You can skip this section if you don’t like coding. Â
The script goes over all layers and items which are placed in the hierarchy below the highlighted layer. It finds all the sublayers and items containing the word left and right in their name. Once all the items are located, the script goes over all of them, finds the string matching left or right, and replaces it with the opposite one.
- Call for a function to find all the items matching the condition. This is a recursive function that goes through through all the nested layers and preforming the search on each of them.
findLayersWithLeftAndRightTags();
- Start with checking the highlighted layer itself: Does the name includes Right or Left words?
- Select all the items on this layer, go through them and check them as well.
if(!layersList)
{
layersList= app.activeDocument.activeLayer.layers;
checkLayerTagLeft(app.activeDocument.activeLayer);
checkLayerTagRight(app.activeDocument.activeLayer);
app.activeDocument.activeLayer.hasSelectedArtwork=true;
var topsel=app.activeDocument.selection;
checkSelectedItems(topsel);
}
- Now perform the check on all the sublayers.
- If the sublayer fits the conditions, store it for later use.
- If the sublayer has nested sublayers, run the same function on all sublayers.
for (var i = 0; i < layersList.length; i++) {
layersList[i].hasSelectedArtwork=true;
var sel=app.activeDocument.selection;
checkSelectedItems(sel);
checkLayerTagLeft(layersList[i]);
checkLayerTagRight(layersList[i]);
if (layersList[i].layers.length) findLayersWithLeftAndRightTags(layersList[i].layers)
}
- Rename all the stored items that matched the conditions.
swapLeftAndRightTags();
function swapLeftAndRightTags(){
for (var i = 0; i < layersWithLeftTag.length; i++)
{
layersWithLeftTag[i].name = layersWithLeftTag[i].name.replace('Left', 'Right');
layersWithLeftTag[i].name = layersWithLeftTag[i].name.replace('left', 'right');
numOfLeftTagsChanged++;
}
for (var i = 0; i < layersWithRightTag.length; i++)
{
layersWithRightTag[i].name = layersWithRightTag[i].name.replace('Right', 'Left');
layersWithRightTag[i].name = layersWithRightTag[i].name.replace('right', 'left');
numOfRightTagsChanged++;
}
for (var i = 0; i < itemsWithRightTag.length; i++)
{
itemsWithRightTag[i].name = itemsWithRightTag[i].name.replace('Right', 'Left');
itemsWithRightTag[i].name = itemsWithRightTag[i].name.replace('right', 'left');
numOfRightTagsChanged++;
}
for (var i = 0; i < itemsWithLeftTag.length; i++)
{
itemsWithLeftTag[i].name = itemsWithLeftTag[i].name.replace('Left', 'Right');
itemsWithLeftTag[i].name = itemsWithLeftTag[i].name.replace('left', 'right');
numOfLeftTagsChanged++;
}
}
Now What?
If you haven’t already, download the remove the word copy from the end of all layer names script.
Use the comment section below to tell us if the script was helpful and what other processes you would like to automate in your workflow.
Stay tuned for new tutorials.
Shop Related Products:
- Facebook38
- Twitter0
- Pinterest1
- Email0
- Subscribe
- 39shares
- Like
- Digg
- Del
- Tumblr
- VKontakte
- Buffer
- Love This
- Odnoklassniki
- Meneame
- Blogger
- Amazon
- Yahoo Mail
- Gmail
- AOL
- Newsvine
- HackerNews
- Evernote
- MySpace
- Mail.ru
- Viadeo
- Line
- Comments
- Yummly
- SMS
- Viber
- Telegram
- Subscribe
- Skype
- Facebook Messenger
- Kakao
- LiveJournal
- Yammer
- Edgar
- Fintel
- Mix
- Instapaper
- Copy Link
but thanks to Katia for the nice article
whats up with this horrendous sociallockerapp. i just want to download the script. i would even like this on twitter on my account. oh well, adios animationguides.com
Hi, stageonemedia!
Thank you for your thoughts! We’ll take it into an account and maybe remove Social Locker App in the future so the user experince will be better. Yes, I agree, the developers of Social Locker App have made it not ideal and annoying, with many bugs and without good technical support.