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

A Script to Reorganize Appearance Panel

Participant ,
May 23, 2024 May 23, 2024

Copy link to clipboard

Copied

Hello community! ðŸ‘‹

 

I’m looking for a script that can apply a blue fill and a yellow stroke to a selection, while the fill appears in front and the stroke in the background within the Appearance panel This is to maintain organization within the panel itself, not merely applying a stroke outside.


Any help would be greatly appreciated! 

TOPICS
Experiment , How-to , Scripting , Tools

Views

176

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

Participant , May 24, 2024 May 24, 2024

After several attempts and modifications, I've finally crafted a script that seems to be functioning correctly. Below is the solution script that worked for me:

 

// Ensure an active document is open and a page item is selected
if (app.documents.length > 0 && app.activeDocument.selection.length > 0) {
    var doc = app.activeDocument;
    var myPageItem = doc.selection[0];

    try {
        // Try to get the graphic style and apply it
        doc.graphicStyles.getByName("StyleName").applyTo(myPag
...

Votes

Translate

Translate
Adobe
Community Expert ,
May 23, 2024 May 23, 2024

Copy link to clipboard

Copied

Unbelievably, the scripting API currently does not provide access to the capabilities of the Appearance Panel, such as applying multiple fills and strokes in arbitrary order. Via scripting we can only access "fillColor" and "strokeColor" with no control of order (stroke is always above fill). Sorry.

- Mark

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
Participant ,
May 23, 2024 May 23, 2024

Copy link to clipboard

Copied

Thanks @m1b

 

Sorry to hear that 

Can this be applied by graphic styles? 

 

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 ,
May 23, 2024 May 23, 2024

Copy link to clipboard

Copied

Ah good question. Graphic styles do contain the appearance attributes as you see them in the appearance panel. 

 

I've never scripted graphic styles, but I had a quick look at the docs and found ArtStyle. You seem to be able to do something like:

var myGraphicStyle = app.activeDocument.graphicStyles.getByName("my style");
myGraphicStyle.applyTo(myPageItem);

I haven't tested, but see if that's helpful.

- Mark 

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
Participant ,
May 24, 2024 May 24, 2024

Copy link to clipboard

Copied

After several attempts and modifications, I've finally crafted a script that seems to be functioning correctly. Below is the solution script that worked for me:

 

// Ensure an active document is open and a page item is selected
if (app.documents.length > 0 && app.activeDocument.selection.length > 0) {
    var doc = app.activeDocument;
    var myPageItem = doc.selection[0];

    try {
        // Try to get the graphic style and apply it
        doc.graphicStyles.getByName("StyleName").applyTo(myPageItem);
    } catch (e) {
        // Handle error silently
    }
}

 

I hope this can be of help to anyone who might be facing similar issues.

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 ,
May 24, 2024 May 24, 2024

Copy link to clipboard

Copied

Well done!

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 ,
May 24, 2024 May 24, 2024

Copy link to clipboard

Copied

LATEST

By the way, this could also be done with a simple action (at least as far as I understand the task).

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