Hello,
My code works perfectly on CS5 Mac but, when running on Windows, the .translate does not execute. Any chance I am doing something wrong on this platform?
Code: Select allvar xiSlider = 600;
var layerY = 200;
var delta = parseInt(xiSlider)-parseInt(activeDocument.activeLayer.bounds[0].value);
activeDocument.activeLayer.translate(delta,layerY)
thanks,
Alex
Translate not working on CS5 Windows 7
Translate not working on CS5 Windows 7
Hello d3mac123
It will work like this :
Code: Select all// Save the current preferences
var startRulerUnits = app.preferences.rulerUnits;
var startTypeUnits = app.preferences.typeUnits;
var startDisplayDialogs = app.displayDialogs;
// Set Adobe Photoshop CS5 to use pixels and display no dialogs
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
app.displayDialogs = DialogModes.NO;
var xiSlider = 600;
var layerY = 200;
var delta = parseInt(xiSlider)-parseInt(activeDocument.activeLayer.bounds[0].value);
activeDocument.activeLayer.translate(delta,layerY)
// Reset the application preferences
app.preferences.rulerUnits = startRulerUnits
app.preferences.typeUnits = startTypeUnits
app.displayDialogs = startDisplayDialogs
It will work like this :
Code: Select all// Save the current preferences
var startRulerUnits = app.preferences.rulerUnits;
var startTypeUnits = app.preferences.typeUnits;
var startDisplayDialogs = app.displayDialogs;
// Set Adobe Photoshop CS5 to use pixels and display no dialogs
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
app.displayDialogs = DialogModes.NO;
var xiSlider = 600;
var layerY = 200;
var delta = parseInt(xiSlider)-parseInt(activeDocument.activeLayer.bounds[0].value);
activeDocument.activeLayer.translate(delta,layerY)
// Reset the application preferences
app.preferences.rulerUnits = startRulerUnits
app.preferences.typeUnits = startTypeUnits
app.displayDialogs = startDisplayDialogs
Translate not working on CS5 Windows 7
Txuku,
Unfortunately, still not working... It is very weird as it works on Mac. You can see what I am developing at http://www.asouza.com/demos/kwik_2.mov (it is a long video but the "issue", not reproduceable on the Mac is demonstrated starting around 3:45 (basically, when I move a slider, I move the layer object).
In my Windows, when I move the slider, the (for example) Shape I drew disapears on the project. If I have another layer, below the layer I am working on, this second layer is simply deleted! Clearly the issue is in the .translate line (i added an alert before and after the line and only the "before" one alerts).
My product is ready to go live but, this BIG issue on Windows is delaying everything. Ideas??
Unfortunately, still not working... It is very weird as it works on Mac. You can see what I am developing at http://www.asouza.com/demos/kwik_2.mov (it is a long video but the "issue", not reproduceable on the Mac is demonstrated starting around 3:45 (basically, when I move a slider, I move the layer object).
In my Windows, when I move the slider, the (for example) Shape I drew disapears on the project. If I have another layer, below the layer I am working on, this second layer is simply deleted! Clearly the issue is in the .translate line (i added an alert before and after the line and only the "before" one alerts).
My product is ready to go live but, this BIG issue on Windows is delaying everything. Ideas??
Translate not working on CS5 Windows 7
It works well for me - win 7 and XP.
Try this line 3 : instead of value you put as.('px') ?
Code: Select allvar delta = parseInt(xiSlider)-parseInt(activeDocument.activeLayer.bounds[0].as('px'));
Try this line 3 : instead of value you put as.('px') ?
Code: Select allvar delta = parseInt(xiSlider)-parseInt(activeDocument.activeLayer.bounds[0].as('px'));
Translate not working on CS5 Windows 7
One thing you can try is this function from StackSupport.jsx. That way you will know if the problem is with the DOM translate method itself or some issue with your custom panel and Win7. Note the comments are part of the Adobe script.
Code: Select all// This is the same as app.activeDocument.activeLayer.translate( dx, dy ),
// which seems to be broken at the moment.
// Potential DOM FIX
function translateActiveLayer( deltaX, deltaY )
{
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( classLayer, typeOrdinal, enumTarget );
desc.putReference( typeNULL, ref );
var coords = new ActionDescriptor();
coords.putUnitDouble( enumHorizontal, unitPixels, deltaX );
coords.putUnitDouble( keyVertical, unitPixels, deltaY );
desc.putObject( keyTo, keyOffset, coords );
executeAction( eventMove, desc, DialogModes.NO );
}
Code: Select all// This is the same as app.activeDocument.activeLayer.translate( dx, dy ),
// which seems to be broken at the moment.
// Potential DOM FIX
function translateActiveLayer( deltaX, deltaY )
{
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( classLayer, typeOrdinal, enumTarget );
desc.putReference( typeNULL, ref );
var coords = new ActionDescriptor();
coords.putUnitDouble( enumHorizontal, unitPixels, deltaX );
coords.putUnitDouble( keyVertical, unitPixels, deltaY );
desc.putObject( keyTo, keyOffset, coords );
executeAction( eventMove, desc, DialogModes.NO );
}
Translate not working on CS5 Windows 7
Mike,
I believe this is something related with Windows. I tried your code but it is still not running. So, I decided to " debug" with alert messages. the first one shows the parameters received (which is correct). the second one " arrived here 1" displays. None of others displays, meaning that the code stopped at ref.putEnumerated( classLayer, typeOrdinal, enumTarget );
Ideas? If you want, I can forward my full code for your revision (it is a big project but it is separeted in different files). thanks again for your support!
Alex
Code: Select allfunction translateActiveLayer( deltaX, deltaY )
{
alert(deltaX+" and "+deltaY)
var desc = new ActionDescriptor();
var ref = new ActionReference();
alert("arrived here 1")
ref.putEnumerated( classLayer, typeOrdinal, enumTarget );
alert(" je me soviens 2")
desc.putReference( typeNULL, ref );
alert(" je me soviens 3")
var coords = new ActionDescriptor();
coords.putUnitDouble( enumHorizontal, unitPixels, deltaX );
coords.putUnitDouble( keyVertical, unitPixels, deltaY );
desc.putObject( keyTo, keyOffset, coords );
alert(desc)
executeAction( eventMove, desc, DialogModes.NO );
alert(" chegou ao translateActiveLayer");
}
I believe this is something related with Windows. I tried your code but it is still not running. So, I decided to " debug" with alert messages. the first one shows the parameters received (which is correct). the second one " arrived here 1" displays. None of others displays, meaning that the code stopped at ref.putEnumerated( classLayer, typeOrdinal, enumTarget );
Ideas? If you want, I can forward my full code for your revision (it is a big project but it is separeted in different files). thanks again for your support!
Alex
Code: Select allfunction translateActiveLayer( deltaX, deltaY )
{
alert(deltaX+" and "+deltaY)
var desc = new ActionDescriptor();
var ref = new ActionReference();
alert("arrived here 1")
ref.putEnumerated( classLayer, typeOrdinal, enumTarget );
alert(" je me soviens 2")
desc.putReference( typeNULL, ref );
alert(" je me soviens 3")
var coords = new ActionDescriptor();
coords.putUnitDouble( enumHorizontal, unitPixels, deltaX );
coords.putUnitDouble( keyVertical, unitPixels, deltaY );
desc.putObject( keyTo, keyOffset, coords );
alert(desc)
executeAction( eventMove, desc, DialogModes.NO );
alert(" chegou ao translateActiveLayer");
}
Translate not working on CS5 Windows 7
Sorry, the code I posted was from Adobe's StackSupport.jsx script. I forgot and didn't notice that the charID calls where replaced with constants. Below is the code with the charID calls so it is standalone.
Code: Select all function translateActiveLayer( deltaX, deltaY )
{
alert(deltaX+" and "+deltaY)
var desc = new ActionDescriptor();
var ref = new ActionReference();
alert("arrived here 1")
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
alert(" je me soviens 2")
desc.putReference( charIDToTypeID('null'), ref );
alert(" je me soviens 3")
//desc.putEnumerated( charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID('Qcsa') );
var coords = new ActionDescriptor();
coords.putUnitDouble( charIDToTypeID('Hrzn'), charIDToTypeID('#Pxl'), deltaX );
coords.putUnitDouble( charIDToTypeID('Vrtc'), charIDToTypeID('#Pxl'), deltaY );
desc.putObject( charIDToTypeID('T '), charIDToTypeID('Ofst'), coords );
alert(desc)
executeAction( charIDToTypeID('move'), desc, DialogModes.NO );
alert(" chegou ao translateActiveLayer")
};
Code: Select all function translateActiveLayer( deltaX, deltaY )
{
alert(deltaX+" and "+deltaY)
var desc = new ActionDescriptor();
var ref = new ActionReference();
alert("arrived here 1")
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
alert(" je me soviens 2")
desc.putReference( charIDToTypeID('null'), ref );
alert(" je me soviens 3")
//desc.putEnumerated( charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID('Qcsa') );
var coords = new ActionDescriptor();
coords.putUnitDouble( charIDToTypeID('Hrzn'), charIDToTypeID('#Pxl'), deltaX );
coords.putUnitDouble( charIDToTypeID('Vrtc'), charIDToTypeID('#Pxl'), deltaY );
desc.putObject( charIDToTypeID('T '), charIDToTypeID('Ofst'), coords );
alert(desc)
executeAction( charIDToTypeID('move'), desc, DialogModes.NO );
alert(" chegou ao translateActiveLayer")
};
Translate not working on CS5 Windows 7
Thanks a lot Mike. You SAVE ME!!!!
I recalculate the deltas and everything is working fine now.
Alex
I recalculate the deltas and everything is working fine now.
Alex