Skip to content

Instantly share code, notes, and snippets.

@mim-Armand
Last active February 3, 2021 15:54
Show Gist options
  • Save mim-Armand/53f825c889995b4a65e0 to your computer and use it in GitHub Desktop.
Save mim-Armand/53f825c889995b4a65e0 to your computer and use it in GitHub Desktop.
// http://armand.eu/blog/working-with-measurement-units-in-adobe-extendscript/
function changeUnitsToPixels(){
if(typeof originalUnitsH === 'undefined') originalUnitsH = app.documents[0].viewPreferences.horizontalMeasurementUnits;
if(typeof originalUnitsV === 'undefined') originalUnitsV = app.documents[0].viewPreferences.verticalMeasurementUnits;
app.documents[0].viewPreferences.horizontalMeasurementUnits = app.documents[0].viewPreferences.verticalMeasurementUnits = MeasurementUnits.pixels;
}
function changeUnitsBack(){
app.documents[0].viewPreferences.horizontalMeasurementUnits = originalUnitsH;
app.documents[0].viewPreferences.verticalMeasurementUnits = originalUnitsV;
delete originalUnitsH;
delete originalUnitsV;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment