Skip to main content
Inspiring
October 23, 2024
Answered

Resize item that works like transform tool

  • October 23, 2024
  • 1 reply
  • 929 views

I'm looking for an example script that can resize a selected object based on a certain boundary (e.g. the top boundary). As I understand, there is a built-in function to set the scale, but it is not the same. Here is an example of the transformation I'm looking for.

And of course, the object can be a clipping mask containing objects that are larger in size than the selected "external" object.

 

This topic has been closed for replies.
Correct answer m1b

it seems this is not the option, look for example
on the left a group with clipping mask (yelow item inside) - appliying the script do not affect the whole item (group)
on the right - a pure clipping mask (i.e. Clip Group) and in this case the script only affects the Clipping Path itself but not the content



Since you are not telling me exactly what you want, I have to follow along... Now it seems like you want to *scale* the whole group? If so, use the PageItem.resize method. Calculate the scale by dividing the new clipping mask height with the old and scale the GroupItem.

- Mark

1 reply

m1b
Braniac
October 23, 2024

Hi @andyf65867865, this can get to be a complex topic, depending on many factors. But for what you describe, this is enough:

item.height = 95;

- Mark 

Inspiring
October 23, 2024

Hi @m1b This seems to work for simple objects, but not for masks. 

m1b
Braniac
October 23, 2024

It works the same for clipping masks but you have to be targeting the clipping mask, not the clipping group. A clipping group contains a path item that has a `clipping` property—that is the one to target.

 

Or if you mean opacity mask then I dont know how to scale those because the scripting API does not provide much access, if any.