[QUOTE=TheMaxx;23583]ah, i see how you’re doing it. I would keep all my business logic and functions in a file you distribute, then just make temp files from python that call into those functions with your values:
Distribute this with your other tools
…
CODE
…
As for getting back the value, i’m not sure where you would look, i doubt the stdout would have it. This approach would probably be a one way road. If you arent going back and forth between python and PS, then dont worry about json just yet.
My pslib does include the require function that lets you write and load modules according to the current js standards. Its similar to a python import.
Let me know if any of that makes sense[/QUOTE]
Well I can’t say that code didn’t confuse me. I had to look up self invoking anonymous function expressions on google.
I’ve spoken to some other people regarding this and every single one of them - including you - suggest writing the jsx-file to the disc on the fly and then executing it.
So afaik it appears that you have to do just that (write a file) or modify an already existing jsx file by opening it in python, find the variable and edit it with string substitution - like this:
with open(script_input_not_edited_yet) as o:
data=o.read()
theInt=55
data=re.sub(r'^(theInt\s*=)\s+\d+;', '\1'+str(theInt)+";")
with open(script_path_after_edit, "w") as w:
w.write(data)
Maybe it’s better to just start looking into JSON…
Do you know of any blogs or have any example code on that matter? (tossing JSON objects in between these apps)
EDIT: Some more questions regarding the Maya<–>Photoshop pipe. Even with the use of writing a JSON-object to the disc, which can be readable by both Python and Javascript, it seems to me that the pipe between these apps would still be one-directional. Python can always tell Photoshop to do stuff via subprocess.Popen. But is it even possible for Photoshop to send instructions to Maya? I guess you could make some kind of Python -listener that looks at the JSON object, and starts doing stuff when changes has been made to the file (such as a variable being changed) - but maybe there are other ways?