/t5/photoshop-ecosystem-ideas/p-ability-to-quot-ruler-origin-quot-by-script/idc-p/12253591#M1623Aug 24, 2016
Aug 24, 2016
Copy link to clipboard
Copied
The path you entered, is too long. Enter a shorter pathFile Name could not be found. Check the spelling of the filename, and verify that the file location is correct.
/t5/photoshop-ecosystem-ideas/p-ability-to-quot-ruler-origin-quot-by-script/idc-p/12255387#M2318Aug 24, 2016
Aug 24, 2016
Copy link to clipboard
Copied
Sorry Albina, I didn't explain myself write. I'm not refering a variable name. I'm refering the x,y position of the origin [0,0] of the rulers. The user can drag and change de [0,0] position.
What I want is to run a script to allow reset the 0,0 relative position to the document top/left position again.
Pedro Marques - Shaping the next era of e-commerce, from polished product images to seamless workflows to AI-generated content.
A couple of thoughts. Scriptlistener doesn't record changing the ruler offset because that is done with the mouse and scriptlistener doesn't record most actions done with the mouse. And I don't see any other way to change it in the GUI using menus or keyboard shortcuts. RulerOriginH and RulerOriginV are two of a document's action descriptor keys. You can use those IDs to get the current offsets. There are some things that you can get but not set and this may be one of those. When I try to construct an executeAction to set the offset the best I can do is set it to 0. That is to say no matter what value I use in the executeAction, the ruler resets to 0. I have never spent a lot of time trying to get setting the offset to work so it may be possible but I suspect that it needs access to the ruler class and action manager does not have that access.
Pedro Marques - Shaping the next era of e-commerce, from polished product images to seamless workflows to AI-generated content.
/t5/photoshop-ecosystem-ideas/p-ability-to-quot-ruler-origin-quot-by-script/idc-p/12255372#M2312Aug 25, 2016
Aug 25, 2016
Copy link to clipboard
Copied
I thought you could do it within the script by setting a variable to the current file path/filename and then close the file with save changes. Open the file using that variable and the origin will be reset to 0,0.
The files I work with are huge and would take too long to save and re-open. If you are dealing with small files, you wouldn't notice much delay.
I had to use offsets like you described above, but it makes my code more complex.
/t5/photoshop-ecosystem-ideas/p-ability-to-quot-ruler-origin-quot-by-script/idc-p/12255368#M2311Aug 26, 2016
Aug 26, 2016
Copy link to clipboard
Copied
Each retoucher open/saves 500 images/day on average. My team has 6500 images/day on average. Can't do that. It's easier to assume de ruler origin has a variable on team scripts.
Pedro Marques - Shaping the next era of e-commerce, from polished product images to seamless workflows to AI-generated content.
/t5/photoshop-ecosystem-ideas/p-ability-to-quot-ruler-origin-quot-by-script/idc-p/12255364#M2309Aug 26, 2016
Aug 26, 2016
Copy link to clipboard
Copied
The offset solution is the only other suggestion I have, here is the code I use:
var ref = new ActionReference(); // figure out where the ruler origin is - we can't change it, but we can offset it
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
var xRulerRawOffSet = desc.getInteger(stringIDToTypeID('rulerOriginH'));
var yRulerRawOffSet = desc.getInteger(stringIDToTypeID('rulerOriginV'));
var xRuler = xRulerRawOffSet/65536 // these are stored as two byte numbers so they need to be divided
var yRuler = yRulerRawOffSet/65536
var desc = new ActionDescriptor(); var ref = new ActionReference(); ref.putProperty(classProperty, krulerOriginHStr); ref.putEnumerated(classDocument, typeOrdinal, enumTarget); desc.putReference(typeNULL, ref); desc.putInteger(keyTo, horiz << 16); executeAction(eventSet, desc, DialogModes.NO);
var desc = new ActionDescriptor(); var ref = new ActionReference(); ref.putProperty(classProperty, krulerOriginVStr); ref.putEnumerated(classDocument, typeOrdinal, enumTarget); desc.putReference(typeNULL, ref); desc.putInteger(keyTo, vert << 16); executeAction(eventSet, desc, DialogModes.NO); }
/////////////////////////////////////////////////////////////////////////////// // Function: GetInfo // Usage: Get information from Photoshop // Input: desiredClass, classApplication, classLayer, etc. // desiredKey, optional specific key to get instead of everything // this is recommended as all keys is an expensive call // Return: ActionDescriptor or single value depending on what is asked for /////////////////////////////////////////////////////////////////////////////// function GetInfo(desiredClass, desiredKey) {
var reference = new ActionReference(); if (typeof desiredKey != "undefined") {
reference.putProperty(stringIDToTypeID("property"), desiredKey); } reference.putEnumerated(desiredClass, stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum")); var desc = executeActionGet(reference); if (typeof desiredKey != "undefined") {
/////////////////////////////////////////////////////////////////////////////// // Function: GetItemFromDescriptor // Usage: Get a specific key from an ActionDescriptor // Input: desc (ActionDescriptor), valid ActionDescriptor to pull info from // desiredKey (Number), key in question, use charIDToTypeID() or // stringIDToTypeID() // Return: ActionDescriptor or single value depending on what is asked for /////////////////////////////////////////////////////////////////////////////// function GetItemFromDescriptor(desc, desiredKey) {
if (desc.hasKey(desiredKey)) {
var typeID = desc.getType(desiredKey); switch (typeID) {
case DescValueType.BOOLEANTYPE: return desc.getBoolean(desiredKey); break; case DescValueType.STRINGTYPE: return desc.getString(desiredKey); break; case DescValueType.DOUBLETYPE: return desc.getDouble(desiredKey); break; case DescValueType.INTEGERTYPE: return desc.getInteger(desiredKey); break; case DescValueType.LARGEINTEGERTYPE: return desc.getLargeInteger(desiredKey); break; case DescValueType.OBJECTTYPE: return desc.getObjectValue(desiredKey); break; case DescValueType.UNITDOUBLE: var newT = desc.getUnitDoubleType(desiredKey); var newV = desc.getUnitDoubleValue(desiredKey); return new UnitValue(newV, newT); break; case DescValueType.ENUMERATEDTYPE: return desc.getEnumerationValue(desiredKey); break; case DescValueType.CLASSTYPE: return desc.getClass(desiredKey); break; case DescValueType.ALIASTYPE: return desc.getPath(desiredKey); break; case DescValueType.RAWTYPE: var tempStr = desc.getData(desiredKey); var rawData = new Array(); for (var tempi = 0; tempi < tempStr.length; tempi++) { rawData[tempi] = tempStr.charCodeAt(tempi); } return rawData; break; case DescValueType.REFERENCETYPE: return desc.getReference(desiredKey); break; case DescValueType.LISTTYPE: return desc.getList(desiredKey); break; default: return; } } return; }