Apply an action to each sublayer

Explorer ,
Jun 04, 2022 Jun 04, 2022

Copy link to clipboard

Copied

Hi,

I have an Illustrator file with a layer containing 300 sub-layers. I need to perform an action on each and every one of those. I have created an action with a key binding, which does speed things up, but it still requires a ton of time to do manually.

 

Is there a way to apply the action to each of the sub-layers? Alternatively, is there a way to tell the action "select the next sub-layer" and to ask Illustrator "run this action 300 times"?

 

Thanks!

TOPICS
How to , Scripting

Views

235

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jun 05, 2022 Jun 05, 2022

Copy link to clipboard

Copied

Further information is needed. At a minimum

  1. What does the action do?
  2. Are we really talking about sublayers? (People here seem to regularly confuse sublayers with objects.)
  3. What does the Layers Panel look like?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 05, 2022 Jun 05, 2022

Copy link to clipboard

Copied

Thanks for your answer.

 

Each sub-layer (might be an object, I am not sure) is a group made of a type element and a shape. A number inside a colored circle. The action simply ungroups, aligns them to each other vertically and horizontally, and re-groups them.

 

The action:

Screen Shot 2022-06-05 at 21.26.41.png

 

 

A sample of the layers panel

Screen Shot 2022-06-05 at 21.26.21.png

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

You could try this script, which goes over selected items (groups in this case) and applies your action to each.  To try it, select few items and run the script. (A word of warning.  I don't know how it will perform with hundreds of items.)

 

// select items to apply action to
var array = [];
var selected = app.activeDocument.selection;
for (var i = 0; i < selected.length; i++) {
    if (selected[i].typename == "GroupItem") {
        array.push(selected[i]);
    }
}
app.selection = null;
for (var i = 0; i < array.length; i++) {
    array[i].selected = true;
    app.doScript("Recenter", "MBL")
    app.selection = null;
}

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

Thank you! I will try it shortly.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 05, 2022 Jun 05, 2022

Copy link to clipboard

Copied

Apart from what Femke rightfully suggested, please provide a sample Illustrator file as well as the action set file.

 

And feel free to explain your plans as detailed as possible.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

You may add another step to the action that would select the next group below (see Select menu) and then duplicate all action steps as often as desired (highlight them and use the Duplicate command in the Actions palette menu).

 

You would get a sequence like this:

 

Action Name
 - Ungroup
 - Align
 - Align
 - Group
 - Next Object Below

--------------------------

 - Ungroup
 - Align
 - Align
 - Group
 - Next Object Below

--------------------------

 - Ungroup
 - Align
 - Align
 - Group
 - Next Object Below

--------------------------

 - Ungroup
 - Align
 - Align
 - Group
 - Next Object Below

--------------------------

 - Ungroup
 - Align
 - Align
 - Group
 - Next Object Below

 

In this case the action would process 5 groups in one go. To use it just select the topmost group and run the action as often as required.

 

You could of course create a very long sequence, but 300 duplicates may be a bit bloated.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

Thank you, that should work. It's a bit dirty/hacky but will cut the amount of time I need to manually run the action by orders of magnitude!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

Yes, actions are always dirty and bumpy.

 

Another question is if you are the actual creator of the files or if you are just edititing files from someone else.

 

If the former, there may be just some alternative ways of creating the numbering circles that may prevent manual alignments right from the start.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

Thanks. I am the creator. The main issue is that the font has uneven height for different characters, so when I change the type (which I have to do for all numbers >n when I insert a new label n), they all get out of alignment. But if there is a way to keep them aligned, that would make me very happy.

 

This is the final result, in case that makes a difference: Mont Blanc Lines.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 07, 2022 Jun 07, 2022

Copy link to clipboard

Copied

Hopefully I'm not supposed to climb all those routes in order to carefully inspect the numbers. But it looks like all circles have the same size, right?

 

In that case you may create a graphic style:

 

- Select any text object with the Selection tool.
- In the Appearance palette add a new fill and drag it below the Character entry.
- Highlight the new fill in the Appearance palette.
- Go to Effect menu > Convert into Shape > Ellipse
- Choose the absolute size option and set the desired size.
- Make a graphic style from that appearance stack. You can reapply it to other type objects later.

 

If there are varying colours you could make a set of different graphic styles or just change the colour of the additional fill in the Appearance palette.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

Thanks very much, that is definitely a different solution. I however am struggling with centering the text exactly. As far as I can tell, my only option if going down that road would be to use the paragraph tools to center the text horizontally and vertically, but the end result looks pretty crooked, at least with that font. Any idea on whether that's fixable?

Screen Shot 2022-06-08 at 09.01.51.png

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

It might be fixed.

 

What font are you using?

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

I am using The Sans in Bold.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

There are three slightly modified graphic styles (Yellow_Marker, Red_Marker and Green_Marker) in the Illustrator file below:

 

Circle Markers

 

You may check if they work with TheSans as well.

 

In the screenshot below I used the styles with some other fonts (Skia, Raleway and Big Caslon).

 

36_02.png

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

Thank you so much! I don't know what I did differently, but your version has the numbers perfectly aligned with The Sans. This will make things so much faster for future files!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

LATEST

Thanks for reporting back and confirming that the styles may work well with TheSans. I don't have that font at the moment.

 

By the way, I visited your Mont Blanc Lines website. There are very impressive photos, especially at the dedicated photography section.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines