Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Photoshop commands undefined. Using Generator Settings #138

Samelot opened this issue Jan 27, 2014 · 3 comments


None yet
2 participants
Copy link

commented Jan 27, 2014

When writing a node js photoshop plugin, I've noticed that certain code causes issues that would normally be acceptable if used in an ordinary .jsx script.

var idslct = charIDToTypeID( "slct" );
var desc2 = new ActionDescriptor();

I researched a little bit and came to this: generator settings.

How do these work?

The setGeneratorSettings.jsx and getGeneratorSettings.jsx seem to be closely related to my issue. Do we need to write some sort of require line at the beginning of our plugin to get access to these?



This comment has been minimized.

Copy link

commented Jan 29, 2014

I'm a bit confused. Are you trying to write statements like var idslct = charIDToTypeID( "slct" ); in code that is passed to Generator.prototype.evaluateJSXFile or Generator.prototype.evaluateJSXString? If so, that should work fine.

Or, are you trying to execute that code inside node? If you're trying to do that, it definitely won't work. ExtendScript code is different than node code. The only way to execute ExtendScript code is to pass it to the functions I mentioned above. This is how all of the JSX files are executed in the directory you linked to.

Happy to try to help further if you can provide me with some more details. In the mean time, this doesn't sound like a bug, so I'm closing the issue.


This comment has been minimized.

Copy link

commented Jan 31, 2014

Great! So it's just photoshop .js code that can be ran in node without passing it to Generator.prototype.evaluateJSXFile or Generator.prototype.evaluateJSXString?

Anyway, in Tom Krcha's "generator-getting-started" repository, I found the code:

function sendJavascript(str){

Using this worked perfectly. I was looking in the "generator-core-master" repository but I couldn't find this same logic. Where in that repository does this same code for passing jsx exist?

Thanks Joel


This comment has been minimized.

Copy link

commented Feb 5, 2014

The evaluateJSXString method is defined here:

Alternatively, you might consider using the evaluateJSXFilemethod:

That method takes two parameters: a path to the file to execute, and an object named params. The params object must be JSONifyable. Whatever is in that params object will also be available in the JSX code in an object named params.

So, if you call: myGenerator.evaluateJSXFile("/path/to/someFile.jsx", {a : 1, b : 2}) then params.a will be equal to 1 and params.b will be equal to 2 when the JSX file executes in Photoshop.

Both methods return a Promise that resolves when the execution is complete. Look elsewhere in the generator.js file for example usage.

Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.