Skip to main content
Inspiring
August 8, 2025
Answered

Rotating a pathItem with opacity mask. Mask doesn't rotate.

  • August 8, 2025
  • 2 replies
  • 548 views

item.rotate(); rotates item but not its opacity mask. There's nothing about this in the reference afaik. Any ideas/workarounds?

-See attached video & file-

I found two similar threads but none of them really touched upon how to do this in scripting.

Correct answer CarlosCanto

there's a way for both extremely complicated topics

1. check if an object has an Opacity Mask

2. transform object with Opacity Mask

 

1. check for Opacity Mask as described in this post by @m1b 

https://community.adobe.com/t5/illustrator-discussions/how-to-use-getdocumentinfoastext/m-p/14206023/thread-id/386366

 

2. turn object with Opacity Mask into a Symbol, transform as usual, remove Symbol...take that chatGPT!

 

// rotate or move Object with Opacity Mask
// Carlos Canto - 8/10/2025

// select a single object with Opacity Mask before running
function main() {
    var idoc = app.activeDocument;

    var sel = idoc.selection[0];

    var newSymbol = idoc.symbols.add(sel, SymbolRegistrationPoint.SYMBOLCENTERPOINT);

    instance = idoc.symbolItems.add(newSymbol);
    instance.position = sel.position;

    selection = null;

    instance.rotate(45);
    
    //instance.translate (instance.width);

    instance.breakLink(); // returns the original compound path inside a layer
    newSymbol.remove();

    var dup = selection[0];
    var parent = dup.parent; // this is the layer that needs to be removed

    dup.move (sel, ElementPlacement.PLACEBEFORE);
    parent.remove();

    sel.hidden = true; // hide for now, it could be removed if not needed

}
main()

 

2 replies

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
August 10, 2025

there's a way for both extremely complicated topics

1. check if an object has an Opacity Mask

2. transform object with Opacity Mask

 

1. check for Opacity Mask as described in this post by @m1b 

https://community.adobe.com/t5/illustrator-discussions/how-to-use-getdocumentinfoastext/m-p/14206023/thread-id/386366

 

2. turn object with Opacity Mask into a Symbol, transform as usual, remove Symbol...take that chatGPT!

 

// rotate or move Object with Opacity Mask
// Carlos Canto - 8/10/2025

// select a single object with Opacity Mask before running
function main() {
    var idoc = app.activeDocument;

    var sel = idoc.selection[0];

    var newSymbol = idoc.symbols.add(sel, SymbolRegistrationPoint.SYMBOLCENTERPOINT);

    instance = idoc.symbolItems.add(newSymbol);
    instance.position = sel.position;

    selection = null;

    instance.rotate(45);
    
    //instance.translate (instance.width);

    instance.breakLink(); // returns the original compound path inside a layer
    newSymbol.remove();

    var dup = selection[0];
    var parent = dup.parent; // this is the layer that needs to be removed

    dup.move (sel, ElementPlacement.PLACEBEFORE);
    parent.remove();

    sel.hidden = true; // hide for now, it could be removed if not needed

}
main()

 

iLLMonkeyAuthor
Inspiring
August 10, 2025

Awesome, Thanks!. Adobe Scripting;  sometimes the solution’s simple, and other times people go on wild adventures just to fix something that feels like it should’ve been there all along.

Sergey Osokin
Inspiring
August 9, 2025

I know only one solution, and it's not the most pleasant one. This is to generate an action inside the script with the rotation angle parameter and apply it to the selected object via app.doScript(), then unload the action. This complicates scripts, so I rarely use this workaround. Unless it is critically important to consider the possible presence of an Opacity Mask in the file. Since objects don't have any Boolean properties to check for Opacity Mask, although we can check for clipped groups.

 

For example, to duplicate a print on a series of T-shirts, the designer said that he uses an Opacity Mask. Then I made an action generation inside the script with the Move command, where the calculated X, Y delta of the duplicate movement were added.