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

Illustrator scripting help. How to know if Live Effect applied?

New Here ,
Aug 26, 2024 Aug 26, 2024

Hello.

I can't figure out, is it possible to know somehow if any Live Effect applied to PageItem or some other object in a document? Using Graphic Styles turned out wrong.

TOPICS
Scripting
460
Translate
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

Community Expert , Aug 26, 2024 Aug 26, 2024

Unfortunately @jonas_5930, we can't know if a Live Effect is applied. The scripting API only gives access to the very basic appearance (1 x fill, 1 x stroke).

 

You can do something hacky like this:

(function () {

    var doc = app.activeDocument,
        item = doc.selection[0];

    var expandedItem = expandAppearance(item.duplicate());

    /* 
    * now compare `item` with `expandedItem` somehow:
    * - different `typename`?
    * - number of paths or pathItems?
    * - different visibleBo
...
Translate
Adobe
Community Expert ,
Aug 26, 2024 Aug 26, 2024

Unfortunately @jonas_5930, we can't know if a Live Effect is applied. The scripting API only gives access to the very basic appearance (1 x fill, 1 x stroke).

 

You can do something hacky like this:

(function () {

    var doc = app.activeDocument,
        item = doc.selection[0];

    var expandedItem = expandAppearance(item.duplicate());

    /* 
    * now compare `item` with `expandedItem` somehow:
    * - different `typename`?
    * - number of paths or pathItems?
    * - different visibleBounds?
    * 
    * Example - a square with Live Effect Drop Shadow:
    *   `item` is a PathItem with 4 pathPoints
    *   `expandedItem` is a GroupItem containing:
    *      - a GrouptItem containing two PathItems, and
    *      - a RasterItem
    * 
    * So from this you can be sure that the square
    * does have some kind of special appearance.
    * I don't know how reliably you'd be able to tell
    * which Live Effect though.
    * 
    * Note: later you will delete `expandedItem`.
    */

    function expandAppearance(item) {
        app.redraw();
        app.executeMenuCommand('expandStyle');
        return app.activeDocument.selection[0];
    };

})();

 

Sometimes that can help. But otherwise, it isn't a good answer for you, sorry.

- Mark 

Translate
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
New Here ,
Aug 26, 2024 Aug 26, 2024

Thanks for the reply.
Well, that's sad news(

Translate
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 ,
Aug 26, 2024 Aug 26, 2024

Yep. 100% agree.

Translate
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 ,
Aug 26, 2024 Aug 26, 2024

Rick Johnson's SelectMenu plugin has a couple of commands to select objects to which live effects are applied.

Perhaps it can help you.

Translate
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
New Here ,
Aug 28, 2024 Aug 28, 2024
LATEST

Thank you very much.

I never heard about this plugin, but I saw similar opportunities in the Astute Graphic Stylism plugin.

Translate
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