Illustrator scripting help. How to know if Live Effect applied?
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.
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.
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
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.