Skip to main content
Known Participant
February 14, 2023
Question

How to layer move to ?

  • February 14, 2023
  • 2 replies
  • 6511 views

How to move the layer with the help of script and place it on another layer. is that possible ?

[moderator cured the message formatting to make it more readable]

This topic has been closed for replies.

2 replies

Stephen Marsh
Community Expert
Community Expert
February 15, 2023

I'm a bit confused. If the video demonstrates the process you want, then what is the problem?

 

Is the video a "real time" recording, or did you create the video to demonstrate the process that you want scripted (therefore it wasn't a live recording)?

 

It also appears that the image is being resized in the video, rather than only being clipped to a new shape?

nandu nagAuthor
Known Participant
February 16, 2023
Sir thanks for your reply. " I'm a bit confused. If the video demonstrates the process you want, then what is the problem? "= Ye moveing ek software se ho raha hai. .. Kya ye script se move & place ho sakta hai
Stephen Marsh
Community Expert
Community Expert
February 16, 2023

Sir....Two rename layers that place the first rename layer on the second rename layer
Every time the first rename layer is the place.....

The script that I have is not working properly ....plz see this

var idRvrs = charIDToTypeID( "Rvrs" );
var desc131 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref38 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref38.putEnumerated( idLyr, idOrdn, idTrgt );
desc131.putReference( idnull, ref38 );
executeAction( idRvrs, desc131, DialogModes.NO );

var newName =("layer name", "/");

var layers = getSelectedLayers();
for (var i = 0; i < layers.length; i ++){
layers[i].name = newName;
}

 


function getSelectedLayers(){
var idGrp = stringIDToTypeID( "groupLayersEvent" );
var descGrp = new ActionDescriptor();
var refGrp = new ActionReference();
refGrp.putEnumerated(charIDToTypeID( "Lyr " ),charIDToTypeID( "Ordn" ),charIDToTypeID( "Trgt" ));
descGrp.putReference(charIDToTypeID( "null" ), refGrp );
executeAction( idGrp, descGrp, DialogModes.ALL );
var resultLayers=new Array();
for (var ix=0;ix<app.activeDocument.activeLayer.layers.length;ix++){resultLayers.push(app.activeDocument.activeLayer.layers[ix])}
var id8 = charIDToTypeID( "slct" );
var desc5 = new ActionDescriptor();
var id9 = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var id10 = charIDToTypeID( "HstS" );
var id11 = charIDToTypeID( "Ordn" );
var id12 = charIDToTypeID( "Prvs" );
ref2.putEnumerated( id10, id11, id12 );
desc5.putReference( id9, ref2 );
executeAction( id8, desc5, DialogModes.NO );
return resultLayers;
}


var idslct = charIDToTypeID( "slct" );
var desc133 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref39 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
ref39.putName( idLyr, "/" );
desc133.putReference( idnull, ref39 );
var idMkVs = charIDToTypeID( "MkVs" );
desc133.putBoolean( idMkVs, false );
var idLyrI = charIDToTypeID( "LyrI" );
var list16 = new ActionList();
list16.putInteger( 107 );
desc133.putList( idLyrI, list16 );
executeAction( idslct, desc133, DialogModes.NO );

var oldPref = app.preferences.rulerUnits
app.preferences.rulerUnits = Units.PIXELS;
var doc = activeDocument;
var iLayer = doc.activeLayer;

layerDown ();

var mLayerB = doc.activeLayer.bounds;
doc.activeLayer = iLayer;
var scale = Math.max((mLayerB[2]-mLayerB[0])/(iLayer.bounds[2]-iLayer.bounds[0]),(mLayerB[3]-mLayerB[1])/(iLayer.bounds[3]-iLayer.bounds[1]));
iLayer.resize (scale*100,scale*100);
iLayer.translate((mLayerB[0]+mLayerB[2])/2-(iLayer.bounds[0]+iLayer.bounds[2])/2,(mLayerB[1]+mLayerB[3])/2-(iLayer.bounds[1]+iLayer.bounds[3])/2);

function layerDown(){
var idslct = charIDToTypeID( "slct" );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idBckw = charIDToTypeID( "Bckw" );
ref1.putEnumerated( idLyr, idOrdn, idBckw );
desc2.putReference( idnull, ref1 );
var idMkVs = charIDToTypeID( "MkVs" );
desc2.putBoolean( idMkVs, false );
var idLyrI = charIDToTypeID( "LyrI" );
var list1 = new ActionList();
list1.putInteger( 3 );
desc2.putList( idLyrI, list1 );
executeAction( idslct, desc2, DialogModes.NO );
};
var idsetd = charIDToTypeID( "setd" );
var desc135 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref40 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref40.putEnumerated( idLyr, idOrdn, idTrgt );
desc135.putReference( idnull, ref40 );
var idT = charIDToTypeID( "T " );
var desc136 = new ActionDescriptor();
var idNm = charIDToTypeID( "Nm " );
desc136.putString( idNm, """/""" );
var idLyr = charIDToTypeID( "Lyr " );
desc135.putObject( idT, idLyr, desc136 );
executeAction( idsetd, desc135, DialogModes.NO ); "

 


You should create a new topic for the rename, perhaps a moderator could split the topic? 

Community Expert
February 14, 2023
Abambo
Community Expert
Community Expert
February 14, 2023

Oh yes, because of the odd formatting, I did read only half of the message. 😉

 

(I deleted my message, as it was obviously not answering the question)

 

ABAMBO | Hard- and Software Engineer | Photographer