Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Photoshop scripting move one group inside of other

I'm trying to move one LayerSet into the other LayerSet in PhotoShop scripting. Here's my code:

// Source
var srcGroup = app.activeDocument.layerSets.add();
srcGroup.name = 'source';

// Target
var targetGroup = app.activeDocument.layerSets.add();
targetGroup.name = 'target';

srcGroup.move(targetGroup, ElementPlacement.INSIDE);

This gives an error "Error 1220: Illegal Argument". If I change the second argument to ElementPlacement.PLACEAFTER, it the error is gone but it is not quite doing what I want.

like image 417
Juriy Avatar asked Oct 17 '25 14:10

Juriy


1 Answers

As you found out not all values of ElementPlacement are valid for all object types. I decided to make a workarround by adding a dummieGroup and place the source before the dummy. At the end the dummy will be removed.

var srcGroup = app.activeDocument.layerSets.add();
srcGroup.name = "source";
var targetGroup = app.activeDocument.layerSets.add();
targetGroup.name = "target";

//adding the dummy INSIDE the target LayerSet
var dummieGroup = targetGroup.layerSets.add();
dummieGroup.name = "dummy";

srcGroup.move(dummieGroup, ElementPlacement.PLACEBEFORE);
dummieGroup.remove();

To remove a layerSet it have to be empty.

like image 138
Markus Avatar answered Oct 19 '25 13:10

Markus