aha - simple and brilliant - 

many thanks, I'll try it out tomorrow.

Cheers
JRAB

On Feb 17, 2014, at 11:39 PM, Ben Dickson <[email protected]> wrote:

> Environment variables would be the if-all-else-fails solution to such a
> problem.
> 
> For example, you would run this when you want to launch the new Nuke
> session:
> 
> os.setenv("PATH_TO_SAVE_NUKE_SCRIPT_TO", "/path/to/thing.nk")
> nuke.scriptNew() # or subprocess.Popen([...])
> 
> 
> Then in a menu.py somewhere:
> 
> 
> def example():
>    path = os.getenv("PATH_TO_SAVE_NUKE_SCRIPT_TO")
> 
>    if path is None:
>        return
>    else:
>        # Clear env var to prevent it passing to further child-processes
>        os.environ['PATH_TO_SAVE_NUKE_SCRIPT_TO'] = ''
>        del os.environ[PATH_TO_SAVE_NUKE_SCRIPT_TO]
> 
>        # Set root name
>        nuke.root()['name'].setValue(path)
> 
> nuke.addOnCreate(example, nodeClass = "Root")
> 
> 
> On 18/02/14 02:23, John RA Benson wrote:
>> Hey there - 
>> 
>> I am wondering if there is a way to push information into an existing nuke 
>> session after it's up? Basically, from and onScriptLoad callback, I might 
>> need to update a script's text and then use a subprocess.Popen to re-launch 
>> the updated nuke script. I don't want it to replace the source until the 
>> user does a save as, so it's temporarily saved and launched from 
>> /var/tmp/someTempFilename.nk . What I would like to do is push one more 
>> command to the script after it's launched, which would be 
>> nuke.root()['name'].setValue('/path/to/originalScript.nk') so when the user 
>> does do a "control-s", the file saves to the correct location instead of the 
>> tmp. If I could copy the tmp and relaunch the updated script from the 
>> original path, there wouldn't be a problem (actually, that's the way I've 
>> been doing it for awhile), but occasionally the script permissions are 
>> locked, so I'm trying to find an alternative. Just by way of information, 
>> nuke.scriptReadText ends up seg faulting, so I'm left
>  with the
> external launch.
>> 
>> Any ideas? 
>> 
>> thanks!
>> JRAB_______________________________________________
>> Nuke-python mailing list
>> [email protected], http://forums.thefoundry.co.uk/
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>> 
> 
> -- 
> ben dickson
> 2D TD | [email protected]
> rising sun pictures | www.rsp.com.au
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to