Jump to content
Alex_M

[AP] Apply a macro to each selected layer?

Recommended Posts

Is it possible to make a macro apply to each selected layer individually? Currently when I run a macro it applies only to the topmost layer out of all selected ones.


Affinity Photo 1.7.3.481 for Windows Windows 10 x64 1903  CPU AMD Threadripper 1950X @3.9 Ghz  RAM 32 GB GPU GTX 1080 Ti FE 11GB NVMe SSD Samsung 960 Pro 512 GB

Share this post


Link to post
Share on other sites

There are ways to select individual layers in a macro so you can apply a set of steps (or another macro) to them one at a time, but it is tricky to get the selection step to work reliably.


Affinity Photo 1.7.3, Affinity Designer 1.7.3, Affinity Publisher 1.7.3; macOS High Sierra 10.13.6 iMac (27-inch, Late 2012); 2.9GHz i5 CPU; NVIDIA GeForce GTX 660M; 8GB RAM
Affinity Photo 1.7.3.155 & Affinity Designer 1.7.3.1 for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 13.1.2

Share this post


Link to post
Share on other sites
On 10/4/2019 at 8:37 PM, Alex_M said:

Is it possible to make a macro apply to each selected layer individually? Currently when I run a macro it applies only to the topmost layer out of all selected ones.

Can you give us a specific example of what it is you want to do?

E.g. Are they all image layers, what would the macro do on a layer?

A sample document may help


Due to the fact that Boris Johnson is now our Prime Minister, punctuation, spelling and grammar will never be worried about ever again.  We now have far bigger problems to be concerned about.

Share this post


Link to post
Share on other sites

I wanted to make a macro that rasterizes all Image layers I've selected because currently the Rasterize command doesn't work on more than one selected layer.


Affinity Photo 1.7.3.481 for Windows Windows 10 x64 1903  CPU AMD Threadripper 1950X @3.9 Ghz  RAM 32 GB GPU GTX 1080 Ti FE 11GB NVMe SSD Samsung 960 Pro 512 GB

Share this post


Link to post
Share on other sites

This may work but it depends on what your workflow and document layout is................

Create a new document and place 5 random images in it

Select the top layer and record the following 2 commands

Rasterize & Trim
Select Layer 1 below current

repeat for the remaining 4 images (image attached)

You now have a macro that will Rasterise 5 image layers assuming they are sequential in your document (just select the top layer then run the macro)

If you have more than 5 image layers just run the macro again from where it ends to do another 5 (repeat as needed)

If you have less than 5 image layers (or multiples of 5) the macro simply ends when there are no more layers to rasterize

If you have 3 images you want to rasterize but have a couple of shapes (or other layers) below them that you do not want to be rasterized, simply deselect the last 2 rasterize commands in the macro before running it

 

 

rasterise.png


Due to the fact that Boris Johnson is now our Prime Minister, punctuation, spelling and grammar will never be worried about ever again.  We now have far bigger problems to be concerned about.

Share this post


Link to post
Share on other sites

Thanks a lot, @carl123 , I'll try this!


Affinity Photo 1.7.3.481 for Windows Windows 10 x64 1903  CPU AMD Threadripper 1950X @3.9 Ghz  RAM 32 GB GPU GTX 1080 Ti FE 11GB NVMe SSD Samsung 960 Pro 512 GB

Share this post


Link to post
Share on other sites
On 10/7/2019 at 8:37 AM, carl123 said:

Select the top layer and record the following 2 commands

Rasterize & Trim
Select Layer 1 below current

It is a pity we can't edit an existing macro to add a step so it could call itself recursively.... :ph34r:


Affinity Photo 1.7.3, Affinity Designer 1.7.3, Affinity Publisher 1.7.3; macOS High Sierra 10.13.6 iMac (27-inch, Late 2012); 2.9GHz i5 CPU; NVIDIA GeForce GTX 660M; 8GB RAM
Affinity Photo 1.7.3.155 & Affinity Designer 1.7.3.1 for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 13.1.2

Share this post


Link to post
Share on other sites

In theory, you can have a macro end by calling (running) another macro which is simply set to run the first macro

Not tried it so you may get into a infinite loop if there's no way to "break" out of it


Due to the fact that Boris Johnson is now our Prime Minister, punctuation, spelling and grammar will never be worried about ever again.  We now have far bigger problems to be concerned about.

Share this post


Link to post
Share on other sites
41 minutes ago, carl123 said:

In theory, you can have a macro end by calling (running) another macro which is simply set to run the first macro

What I mean is how do you get a macro to run another macro that can't do that until the first macro is created?

IOW, say you are creating a macro with "rasterize & trim" & "select layer 1 below current" as the first 2 steps. To add a third step to call another macro that in turn runs the first macro, the second macro must exist, & it must call the first macro, right? But the first macro has not yet been saved, so the second macro can't call it.

I probably am not explaining this very clearly, but it seems like without the ability to edit an existing macro by adding a step to it, there is no way to do this (because the edited macro has to be saved as a new macro).

Am I missing something here?


Affinity Photo 1.7.3, Affinity Designer 1.7.3, Affinity Publisher 1.7.3; macOS High Sierra 10.13.6 iMac (27-inch, Late 2012); 2.9GHz i5 CPU; NVIDIA GeForce GTX 660M; 8GB RAM
Affinity Photo 1.7.3.155 & Affinity Designer 1.7.3.1 for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 13.1.2

Share this post


Link to post
Share on other sites
5 minutes ago, R C-R said:

but it seems like without the ability to edit an existing macro by adding a step to it

You can effectively do that

But it looks like the problem is that when you tell macro1 to run macro2, macro1 simply copies the commands from macro2 into itself.

So it makes no difference to how you then change macro2 as macro1 never actually runs it

 

 


Due to the fact that Boris Johnson is now our Prime Minister, punctuation, spelling and grammar will never be worried about ever again.  We now have far bigger problems to be concerned about.

Share this post


Link to post
Share on other sites
1 minute ago, carl123 said:

So it makes no difference to how you then change macro2 as macro1 never actually runs it

How do you change an existing macro? If I edit any macro to add a step to it, the only way I know to make the edit permanent is to save it as a new macro.


Affinity Photo 1.7.3, Affinity Designer 1.7.3, Affinity Publisher 1.7.3; macOS High Sierra 10.13.6 iMac (27-inch, Late 2012); 2.9GHz i5 CPU; NVIDIA GeForce GTX 660M; 8GB RAM
Affinity Photo 1.7.3.155 & Affinity Designer 1.7.3.1 for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 13.1.2

Share this post


Link to post
Share on other sites

Save it with the same name and delete the old one of the same name


Due to the fact that Boris Johnson is now our Prime Minister, punctuation, spelling and grammar will never be worried about ever again.  We now have far bigger problems to be concerned about.

Share this post


Link to post
Share on other sites
7 minutes ago, carl123 said:

Save it with the same name and delete the old one of the same name

I am not 100% certain but I am reasonably sure macros do not call other macros based on their name references but by some internal UID. Otherwise, since several entirely different macros could have the same name, how would a macro decide which one to copy into its own steps?


Affinity Photo 1.7.3, Affinity Designer 1.7.3, Affinity Publisher 1.7.3; macOS High Sierra 10.13.6 iMac (27-inch, Late 2012); 2.9GHz i5 CPU; NVIDIA GeForce GTX 660M; 8GB RAM
Affinity Photo 1.7.3.155 & Affinity Designer 1.7.3.1 for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 13.1.2

Share this post


Link to post
Share on other sites

It does not really matter if macros have the same name, the one you select (with the mouse) will have its contents copied into the other macro


Due to the fact that Boris Johnson is now our Prime Minister, punctuation, spelling and grammar will never be worried about ever again.  We now have far bigger problems to be concerned about.

Share this post


Link to post
Share on other sites
1 hour ago, carl123 said:

It does not really matter if macros have the same name, the one you select (with the mouse) will have its contents copied into the other macro

Then there is no point in re-saving the macro with the same name & deleting the old one, right?


Affinity Photo 1.7.3, Affinity Designer 1.7.3, Affinity Publisher 1.7.3; macOS High Sierra 10.13.6 iMac (27-inch, Late 2012); 2.9GHz i5 CPU; NVIDIA GeForce GTX 660M; 8GB RAM
Affinity Photo 1.7.3.155 & Affinity Designer 1.7.3.1 for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 13.1.2

Share this post


Link to post
Share on other sites

You're mixing up two questions you initially raised.

"re-saving the macro with the same name & deleting the old one"

is in relation to when you asked...

"How do you change an existing macro? If I edit any macro to add a step to it, the only way I know to make the edit permanent is to save it as a new macro"

not in any way connected to...

"It does not really matter if macros have the same name, the one you select (with the mouse) will have its contents copied into the other macro"

Which was a response to the discussion on creating a recursive macro

 


Due to the fact that Boris Johnson is now our Prime Minister, punctuation, spelling and grammar will never be worried about ever again.  We now have far bigger problems to be concerned about.

Share this post


Link to post
Share on other sites
1 hour ago, carl123 said:

You're mixing up two questions you initially raised.

Yes I am, but I was just trying to point out that there is no way to create a recursive macro, even using the two macro workaround you suggested.


Affinity Photo 1.7.3, Affinity Designer 1.7.3, Affinity Publisher 1.7.3; macOS High Sierra 10.13.6 iMac (27-inch, Late 2012); 2.9GHz i5 CPU; NVIDIA GeForce GTX 660M; 8GB RAM
Affinity Photo 1.7.3.155 & Affinity Designer 1.7.3.1 for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 13.1.2

Share this post


Link to post
Share on other sites
25 minutes ago, R C-R said:

but I was just trying to point out that there is no way to create a recursive macro, even using the two macro workaround you suggested.

What I also said was "In theory" and "Not tried it"

Which means you would need to try it to see if the theory was true or false

Only after having now tried it can we conclude that the way macros currently work we cannot call another macro to create a recursive loop back to the original macro.

 


Due to the fact that Boris Johnson is now our Prime Minister, punctuation, spelling and grammar will never be worried about ever again.  We now have far bigger problems to be concerned about.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

These are the Terms of Use you will be asked to agree to if you join the forum. | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.