Highlighted

[Script] Duplicate and add same scale value

New Here ,
Oct 02, 2020

Copy link to clipboard

Copied

How to write a script that duplicate a shape, and adds the same value to the scale.

 

For example let's say I have this shape:

1.png

After running the script it will become like this:

2.png

It keeps increasing by 20%.

Thank you!

TOPICS
How to, Scripting

Views

53

Likes

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

[Script] Duplicate and add same scale value

New Here ,
Oct 02, 2020

Copy link to clipboard

Copied

How to write a script that duplicate a shape, and adds the same value to the scale.

 

For example let's say I have this shape:

1.png

After running the script it will become like this:

2.png

It keeps increasing by 20%.

Thank you!

TOPICS
How to, Scripting

Views

54

Likes

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
Oct 02, 2020 0
Greg1987 LATEST
Explorer ,
Oct 02, 2020

Copy link to clipboard

Copied

You can do this really easy with just an expression in the scale.

x = index * 20 + value[1];
[x,x]

You may need to offset the index if the shapes aren't at the top of the layer stack. You can do this manallly, hooking it up to a slider or make a null layer that sits at the top of these layers and use 

-parent.index

If you want to do it via script.

var selectedLayer = app.project.activeItem.selectedLayers[0];
var multiplier = 10;

for (var i = 1; i <= multiplier; i++){
        var dupedLayer = selectedLayer.duplicate();
        amount = dupedLayer.transform.scale.value[0] + 20 * i
        dupedLayer.transform.scale.setValue([amount,amount])
    }

If the shapes have animation on them, then it gets a bit more complicated. 

Likes

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
Reply
Loading...
Oct 02, 2020 0