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

resizing or moving an opacity mask along with the items inside it

Guest
Jul 25, 2013 Jul 25, 2013

Copy link to clipboard

Copied

I'm trying to resize a opacity mask by doing

transMaskItem.resize(

  10, //scaleX,

  10, //scaleY,

  true, //[,changePositions]

  true, //[,changeFillPatterns]

  true, //[,changeFillGradients]

  true, //[,changeStrokePattern]

  0.1, //[,changeLineWidths]

)

This resizes the item, but it does not resize the item inside it. I tried similar command with the translation command

transMaskItem.translate(

100, //([deltaX]

100. //[,deltaY]

True, //[,transformObjects]

True, //[,transformFillPatterns]

True, //[,transformFillGradients]

True, //[,transformStrokePatterns])

and similar thing happened. The item gets moved, but the object inside it doesn't.

How do I resize or translate an opacity mask along with the items inside it?

TOPICS
Scripting

Views

1.6K

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
Adobe
Community Expert ,
Jul 25, 2013 Jul 25, 2013

Copy link to clipboard

Copied

let us know what transMaskItem is referring to.

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
Guest
Jul 25, 2013 Jul 25, 2013

Copy link to clipboard

Copied

it's the PageItem that refers to the opacity mask object.

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 ,
Jul 25, 2013 Jul 25, 2013

Copy link to clipboard

Copied

it seems you're grabbing a hold of the actual mask, you need to resize the "whole" group.

show some more of your code.

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
Guest
Jul 25, 2013 Jul 25, 2013

Copy link to clipboard

Copied

Here is my code:

doc = app.activeDocument;

doc.selectObjectsOnActiveArtboard();

for ( i = 0; i < doc.Selected.length; i++ ) {

    doc.Selected.resize(10, 10, true, true, true, true, 0.1);

     doc.Selected.translate(100, 100, true, true, true, true);

}

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 ,
Jul 25, 2013 Jul 25, 2013

Copy link to clipboard

Copied

I see...it seems to be a bug, the actual mask gets ignored. Probably to be consistent with the user interface, you can not select the mask with the mouse either.

maybe someone else has found a way to work with Opacity Masks, I haven't.

as a side note, there's no need to select the objects in order to size them or move them, you can just reference them. Also, there's no "Selected" object, change that to "selection".

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
New Here ,
Nov 04, 2015 Nov 04, 2015

Copy link to clipboard

Copied

Is this still a bug? Facing the same issue even with Adobe CC 2014 version.

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 ,
Apr 17, 2017 Apr 17, 2017

Copy link to clipboard

Copied

Hey!

I'm still bumping into this problem in CC 2015 😞

I haven't found a good way to resize an opacity mask, but a work-around for translating them is to translate the artboard bounds in the opposite direction.

var doc = app.activeDocument;

var bounds = doc.artboards[0].artboardRect;

var dX = -72; // one inch (in points) to the left, mask will move to the right

var dY = 144; // two inches (in points) up, mask will move down

var wid = Math.abs( bounds[2] - bounds[0] );

var hei = Math.abs( bounds[3] - bounds[1] );

// assume that the active layer is unlocked and visible

var tempRect = doc.activeLayer.pathItems.rectangle( bounds[1] + dY, bounds[0] + dx, wid, hei );

doc.artboards[0].artboardRect = tempRect.geometricBounds;

tempRect.remove();

You will need to also move any elements that you want to "stay in the same place", so this hack probably won't work if you have multiple opacity masks and don't want to translate them all.

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
Enthusiast ,
Apr 17, 2017 Apr 17, 2017

Copy link to clipboard

Copied

LATEST

Another way:

var effectStr =  '<LiveEffect name="Adobe Transform">'

    + '<Dict data="B transformPatterns 0 R scaleV_Factor 1.2 R moveH_Pts 0 R scaleV_Percent 120 B reflectX 0 B scaleLines 0 B reflectY 0 I numCopies 0 B randomize 0 R scaleH_Factor 1.2 R rotate_Radians 0 I pinPoint 4 R moveV_Pts 0 R rotate_Degrees 0 R scaleH_Percent 120 B transformObjects 1 "/>'

    + '</LiveEffect>'; 

app.selection[0].applyEffect(effectStr);

app.redraw();

app.executeMenuCommand('expandStyle');

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