What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Reply to thread

[USER=147373]@Sator[/USER] - As correctly indicated by [USER=65083][ iLLuSioN ][/USER] – you need to explicitly set ruler units, unless you know (not assume) that the current ruler units are correct (px). You should always compare AI-generated code to the docs, as sometimes generative LLMs provide fake, non-existent code to be "helpful", sometimes referred to as a "hallucination":


https://theiviaxx.github.io/photoshop-docs/Photoshop/Documents/add.html#documents-add


Another equivalent approach, where the original ruler units are captured in a variable, then the ruler units are set to px and a new document is created, before returning the original ruler units:


[CODE=javascript]

// Set the ruler units

var origUnits = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS;


app.documents.add(900, 13000, 300, "MyDocument", NewDocumentMode.RGB);


// Restore the original ruler units

app.preferences.rulerUnits = origUnits;

[/CODE]


Happy coding!


What is our favorite program/app? (Hint - it begins and ends with the letter P)
Back
Top