Accessing Opacity Mask is impossible with scripting
There is no way to work with the transparency mask in the Script SDK. This is the least of the problems. But when creating scripts to modify objects with masks, developers expect masks to be modified along with the parent object. After all, we see the "Linked to Art" icon in the Transparency panel.
But what we have all these years as script developers: resize(), position, translate() modify the object, and its mask remains as it was.
I've counted about 10 of my own scripts that use similar commands. I also have a large collection of other developers' scripts, where about 70 scripts contain similar commands. So none of them will help users automate operations with their art.
More than once I've had users come to me and ask, "Where did the opacity mask go after I ran the script? The only solution is to add dynamic actions with Move, Scale with calling app.doScript(). But this introduces many other problems and inconveniences.
-
Ellie commented
There is a problem with the way Extendscript handles moving of groups in Illustrator. If a group has a transparency mask locked to it, the mask will not move with the group when the group is moved via the `Group.translate()` method (the different boolean options have no effect whatsoever on the raster transparency mask) or by setting the group's `top` and `left` object properties. When the mask is locked to the group in the Transparency window in the UI, it will move with the group when moved via any of the UI methods of moving (click and drag, or Object > Transform > Move). However, when the group is moved with Extendscript, it behaves as if the transparency mask is unlocked, regardless of whether it actually is or not. I've attached screenshots showing the before and after of the move attempted with Extendscript. The transparency mask is clearly locked to the group, but the move only changes the position of the group itself, not the transparency mask attached to it. This issue appears regardless of the number of objects in the transparency mask, regardless of whether the objects are vector or raster, and regardless of whether the objects in the mask are grouped to one another.
Illustrator 29.5.1 (64-bit)
Windows 11 Enterprise (version: 24H2, OS build: 26100.3775, experience: Windows Feature Experience Pack 1000.26100.66.0) -
Anonymous commented
+1 should be fixed
-
Sergey Osokin
commented
Of course, there are similar problems when using resize(), rotate() methods, when the object is scaled or rotated, but its transparency mask remains unchanged.
-
dean
commented
Transparency / Opacity Mask - In layers pallet page item names look different with masks (underline) and opacity masks (dashed). It would be great if you could add this to properties of the page item like mask: none, opacity mask or mask. Identifying these objects is even harder then Envelopes which can only be identified by identifying as plugin object. Worst case putting info in the tag propery would be better then nothing when cresating it. I do not believe a opacity mask can be identified through any form of SDK/Script which makes identifying raster images in the file impossible. The other option would be to have the raster item still listed when it is part of opacity mask. Also on this site an option should be all so that not SDK/Script specific.