Thanks for the suggestions! Another suggestion that was made internally was to check the nuke.root().name() before and after the scriptOpen call. If it's changed it's safe to say it opened in the currently running session. I may look at using callbacks like onScriptLoad, but the trick is this code is meant to run in many different DCC's so shuffling things around to work with a callback may not end up working out.
Thanks again for the replies! Best, Tony On Fri, May 9, 2014 at 5:15 AM, Ben Dickson <[email protected]> wrote: > Sounds like there might be a tidier solution to the problem you are > trying to fix (like doing the setup in a onScriptLoad callback or > something), but.. to answer your specific question: > > Checking if the script is both untitled and not modified might be a > reasonably reliable indication, e.g: > > if nuke.root().name() == "Root" and not nuke.root().modified(): > # unsaved + not modified, so opening will use current instance > ... > > The only thing that might break it is "File > Clear"... but not tested > this at all. > > Alternatively you could force it to always open a new instance (maybe by > temporarily setting the modified flag before calling nuke.scriptOpen, or > calling subprocess.Popen([nuke.env['Executable'])) > > On 09/05/14 05:03, Tony Barbieri wrote: > > Hello! > > > > Is there a method or a way to see if scriptOpen will launch a new Nuke > > session or if it will open the script in the current session when > > evaluated? If a new Nuke session will be launched then I don't need to > > do anything, if not I will need to execute some additional code to setup > > environment features. > > > > nuke.root().modified() isn't enough because the open script may have > > nodes in it but remain unmodified. Is it as simple as seeing if the > > root has children nodes underneath it? I'm not sure the mechanism Nuke > > is using to determine if a new session is required or not. > > > > Thanks for any help! > > > > -- > > Tony Barbieri > > > > > > _______________________________________________ > > Nuke-dev mailing list > > [email protected], http://forums.thefoundry.co.uk/ > > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev > > > > -- > ben dickson > 2D TD | [email protected] > rising sun pictures | www.rsp.com.au > _______________________________________________ > Nuke-dev mailing list > [email protected], http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev > -- -tony
_______________________________________________ Nuke-dev mailing list [email protected], http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
