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

Moving groups inside other groups

Enthusiast ,
Jul 15, 2015 Jul 15, 2015

Copy link to clipboard

Copied

Seems really basic, but keep having problems moving a group inside another group (tested CC 2014 and 2015). So following code throws an illegal argument error at the .move-line (I've also tried other variants like .PLACEATBEGINNING and .INSIDE):

var doc = app.documents.add( 256, 256, 72, "foo")

var group1 = doc.layerSets.add()

var group2 = doc.layerSets.add()

group1.move(group2, ElementPlacement.PLACEATEND)

doc.close(SaveOptions.DONOTSAVECHANGES)

But this way works OK

var doc = app.documents.add( 256, 256, 72, "foo")

var group1 = doc.layerSets.add()

var group2 = doc.layerSets.add()

var layer1 = group1.artLayers.add()

var layer2 = group2.artLayers.add()

group1.move(layer2 , ElementPlacement.PLACEAFTER)

doc.close(SaveOptions.DONOTSAVECHANGES)

Any cracked what limitations are in play here? You can do latter, but then you might need to create & remove tmp layers to use as target.

TOPICS
Actions and scripting

Views

1.1K

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

correct answers 1 Correct answer

Enthusiast , Jul 15, 2015 Jul 15, 2015

Yes it has been a problem, but you can use AM.

var doc = app.documents.add( 256, 256, 72, "foo");

doc.layerSets.add();

var group1 = getLayerID();

doc.layerSets.add();

var group2 = getLayerID();

moveLayerToLayerSet( group2, group1);

function moveLayerToLayerSet( fromID, toID ){

var desc5 = new ActionDescriptor();

var ref4 = new ActionReference();

ref4.putIdentifier( charIDToTypeID('Lyr '), Number(fromID) );

desc5.putReference( charIDToTypeID('null'), ref4 );

var ref5 = new ActionReference();

r

...

Votes

Translate

Translate
Adobe
Enthusiast ,
Jul 15, 2015 Jul 15, 2015

Copy link to clipboard

Copied

Yes it has been a problem, but you can use AM.

var doc = app.documents.add( 256, 256, 72, "foo");

doc.layerSets.add();

var group1 = getLayerID();

doc.layerSets.add();

var group2 = getLayerID();

moveLayerToLayerSet( group2, group1);

function moveLayerToLayerSet( fromID, toID ){

var desc5 = new ActionDescriptor();

var ref4 = new ActionReference();

ref4.putIdentifier( charIDToTypeID('Lyr '), Number(fromID) );

desc5.putReference( charIDToTypeID('null'), ref4 );

var ref5 = new ActionReference();

ref5.putIndex( charIDToTypeID('Lyr '), getLayerIndexByID(toID) );

desc5.putReference( charIDToTypeID('T   '), ref5 );

desc5.putBoolean( charIDToTypeID('Adjs'), false );

desc5.putInteger( charIDToTypeID('Vrsn'), 5 );

try{

executeAction( charIDToTypeID('move'), desc5, DialogModes.NO );

}catch(e){alert(e);}

};

function getLayerID(){

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID('Lyr '),charIDToTypeID('Ordn'),charIDToTypeID('Trgt') );

var desc = executeActionGet(ref);

return desc.getInteger(stringIDToTypeID( 'layerID' ));

};

function getLayerIndexByID(ID){

var ref = new ActionReference();

ref.putIdentifier( charIDToTypeID('Lyr '), ID );

try{

activeDocument.backgroundLayer;

return executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1;

}catch(e){

return executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ));

}

};

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 ,
Jul 15, 2015 Jul 15, 2015

Copy link to clipboard

Copied

LATEST

Thanks. Amazingly I've managed to (unintentionally) avoid this issue so far by always moving layers to document root. But now with Artboards can't be avoided

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