• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Is it possible to select a sublayer through ExtendScript?

Community Beginner ,
Jul 26, 2023 Jul 26, 2023

Copy link to clipboard

Copied

CleanShot 2023-07-26 at 17.00.04.png

I need a script thats going to select this layer and then export it as a png. But Im getting stuck on not being able to even select it thought extendscript. Any advice or help? 

TOPICS
Scripting

Views

259

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

correct answers 1 Correct answer

Enthusiast , Jul 27, 2023 Jul 27, 2023

Envelope objects are of type PluginItem. If you know for sure that there are no other pluginItems in the document, you can select them this way:

app.activeDocument.pluginItems[0].selected = true;

 

Votes

Translate

Translate
Adobe
Community Beginner ,
Jul 26, 2023 Jul 26, 2023

Copy link to clipboard

Copied

Ok so this is tripping me out but this below only works when after manually change the Envelope object to Envelope by clicking on it and renaming it. Is there anyway to go about doing this without running into that issue?

(function() {
var doc = app.activeDocument;
 
// Get the items by name
var object1 = doc.pageItems.getByName("Envelope");

// Select both objects
doc.selection = [object1];

})();

Votes

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 Beginner ,
Jul 26, 2023 Jul 26, 2023

Copy link to clipboard

Copied

The plot thickens. It turns out when you warp a text it'll create an Envelope distort sub layer, this isn't a revelation it's just the beginning to the episode that's playing in my head, But I've found out with the use of another script that tells me the name of a selected object it's not Envelope. It seems as soo that when illustrator make an envelop distort object it calls it Envelope in the layers panel but it's actually called Unnamed. And you as far I'm aware you can select this object without having to manually type in Envelope again in the layers panel even thought it's already called that. Thank you for tunning into this hour's episode tune in next hour where I hopefully figure this out. Same manic meltdown time, same manic meltdown channel. 

Votes

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
Guide ,
Jul 27, 2023 Jul 27, 2023

Copy link to clipboard

Copied

When you distort an item with an envelope, you create an unnamed pluginItem. So, unless you name it, you cannot target it by name. If it's always the topmost item in the "base" layer or the one pluginItem in the "base" layer, you could target it that way.

Votes

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
Enthusiast ,
Jul 27, 2023 Jul 27, 2023

Copy link to clipboard

Copied

Envelope objects are of type PluginItem. If you know for sure that there are no other pluginItems in the document, you can select them this way:

app.activeDocument.pluginItems[0].selected = true;

 

Votes

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 ,
Jul 27, 2023 Jul 27, 2023

Copy link to clipboard

Copied

Envelopes like any other item you create, ie text items, path items, etc don't have names. You would have to name items explicitly in the layers panel (if you working manually). You don't have to name the unnamed envelope as "Envelope", you can name it anything else that it more descriptive.

Votes

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 ,
Jul 27, 2023 Jul 27, 2023

Copy link to clipboard

Copied

LATEST

Im sensing an "X Y problem" here.

you want to export a PNG, but youre asking about how to select a layer.

The bad news: Layers can't be selected via script, as far as i know..

The good news: You don't need to. if you only want to export stuff on a certain layer(s), you can simply hide the other layers and then export normally.

 

The confusion: you said youre trying to select a layer, but all of your descriptions are about trying to select an envelope/plugin item...? are you trying to export a png of just that envelope item without anything else?

Votes

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