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

Move LayerSet to another

New Here ,
Nov 15, 2011 Nov 15, 2011

Copy link to clipboard

Copied

Hi,

I have small problam with move one layerset to another.

PS_move_layer_help.jpg

var folder = app.activeDocument.layerSets.add();

app.activeDocument.activeLayer.name = app.activeDocument.name;

for(var j = layers.length-1; j >= 0; j--){

        var layer = layers;

        app.activeDocument.activeLayer = layer;

        if(layer != folder) {

            layer.move(folder, ElementPlacement.INSIDE); // <=========== HERE IS PROBLEM

        }

}

I want move layerset STAR to STAR.PSD with all content.

Can you tell me, where is problem??

Than you Domaneni

TOPICS
Actions and scripting

Views

5.5K

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

Guru , Nov 15, 2011 Nov 15, 2011

Where you able to get the scriptlistener log to output using the layerSet name in the to reference or did you edit the log file? I have only been able get it to output index. And it doesn't seem to work by name. I would do something like this.

var sourceLayerSet = app.activeDocument.layers.getByName('Star');

var destinationLayerSet = app.activeDocument.layers.getByName('Star.psd');

moveLayerSet( sourceLayerSet, destinationLayerSet );

function moveLayerSet( fromLayer, toLayer ){// layerSet objects

   

...

Votes

Translate

Translate
Adobe
Guru ,
Nov 15, 2011 Nov 15, 2011

Copy link to clipboard

Copied

For what it is worth, trying to move a layerset into another layerset has never worked for me either.

// throws Illegal Argument error

//app.activeDocument.layers.getByName('Star').move(app.activeDocument.layers.getByName('Star.psd'),ElementPlacement.INSIDE);

// throws error saying you can't dupe set into another set

// but you can in the GUI or by using scriptlistener

//app.activeDocument.layers.getByName('Star').duplicate(app.activeDocument.layers.getByName('Star.psd'),ElementPlacement.INSIDE);

// does move the artLayer

app.activeDocument.layers.getByName('Star').artLayers[0].move(app.activeDocument.layers.getByName('Star.psd'),ElementPlacement.INSIDE);

// does dupe the artLayer

app.activeDocument.layers.getByName('Star').artLayers[0].duplicate(app.activeDocument.layers.getByName('Star.psd'),ElementPlacement.INSIDE);

As noted you can move or dupe a layerset into another layerset using scriptlistener. But you have to work out the layerSets's Action Manager index.

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
New Here ,
Nov 15, 2011 Nov 15, 2011

Copy link to clipboard

Copied

I wrote this, but it isn't corect.

Can you help me with this??

function moveLayerToLayer(fromLayer, toLayer){

    var id766 = charIDToTypeID( "slct" );

    var desc45 = new ActionDescriptor();

    var id767 = charIDToTypeID( "null" );

    var ref9 = new ActionReference();

    var id768 = charIDToTypeID( "Lyr " );

    ref9.putName( id768, fromLayer);

    desc45.putReference( id767, ref9 );

    var id769 = charIDToTypeID( "MkVs" );

    desc45.putBoolean( id769, false );

    executeAction( id766, desc45, DialogModes.NO);

    //=====================================

    var id770 = charIDToTypeID( "move" );

   

   

    var desc46 = new ActionDescriptor();

    var id771 = charIDToTypeID( "null" );

    var ref10 = new ActionReference();

    var id772 = charIDToTypeID( "Lyr " );

    var id773 = charIDToTypeID( "Ordn" );

    var id774 = charIDToTypeID( "Trgt" );

    ref10.putEnumerated( id772, id773, id774 );

    desc46.putReference( id771, ref10 );

    var id775 = charIDToTypeID( "T   " );

    var ref11 = new ActionReference();

    var id776 = charIDToTypeID( "Lyr " );

    ref11.putName( id776, toLayer);

    desc46.putReference( id775, ref11 );

    var id777 = charIDToTypeID( "Vrsn" );

    desc46.putInteger( id777, 2 );

    executeAction( id770, desc46, DialogModes.NO );

   

}

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
Guru ,
Nov 15, 2011 Nov 15, 2011

Copy link to clipboard

Copied

Where you able to get the scriptlistener log to output using the layerSet name in the to reference or did you edit the log file? I have only been able get it to output index. And it doesn't seem to work by name. I would do something like this.

var sourceLayerSet = app.activeDocument.layers.getByName('Star');

var destinationLayerSet = app.activeDocument.layers.getByName('Star.psd');

moveLayerSet( sourceLayerSet, destinationLayerSet );

function moveLayerSet( fromLayer, toLayer ){// layerSet objects

    var desc = new ActionDescriptor();

        var sourceRef = new ActionReference();

        sourceRef.putName( charIDToTypeID( "Lyr " ), fromLayer.name );

    desc.putReference( charIDToTypeID( "null" ), sourceRef );

            var indexRef = new ActionReference();

            indexRef.putName( charIDToTypeID("Lyr "), toLayer.name );

            var layerIndex = executeActionGet(indexRef).getInteger(stringIDToTypeID('itemIndex'));

        var destinationRef = new ActionReference();

        destinationRef.putIndex( charIDToTypeID( "Lyr " ), layerIndex-1 );

    desc.putReference( charIDToTypeID( "T   " ), destinationRef );

    desc.putBoolean( charIDToTypeID( "Adjs" ), false );

    desc.putInteger( charIDToTypeID( "Vrsn" ), 5 );

    executeAction( charIDToTypeID( "move" ), desc, DialogModes.NO );

}

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
New Here ,
May 11, 2018 May 11, 2018

Copy link to clipboard

Copied

LATEST

It is working with same layer name?

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