// UnitValue examples // This example shows how to use the UnitValue object // when creating documents. UnitValue is used in many methods and properties // in the Photoshop DOM. UnitValue allows conversions from pixels to inches // for example. // To Use: // set exampleToRun to 1 // Reset Photoshop preferences // Restart photoshop // increment this value and run again to see each example in turn var exampleToRun = 1; if ( exampleToRun == 1 ) { // 1) documents.add( 10000, 10000 ); } else if ( exampleToRun == 2 ) { // 2) app.preferences.rulerUnits = Units.PIXELS; documents.add( 10000, 10000 ); } else if ( exampleToRun == 3 ) { // 3) app.preferences.rulerUnits = Units.INCHES; documents.add( UnitValue(10000, "px"), UnitValue(10000, "px") ); } else if ( exampleToRun == 4 ) { // 4) app.preferences.rulerUnits = Units.INCHES; var doc72 = documents.add( UnitValue(10000, "px"), UnitValue(10000, "px"), 72 ); var doc144 = documents.add( UnitValue(10000, "px"), UnitValue(10000, "px"), 144 ); alert( doc72.width.as('in') + " : " + doc144.width.as('in')); } else { alert( 'bad exampleToRun ' + exampleToRun ); }