Forum Groups
  All forums
    Help & Feedback
      Work in progress
      Finished Art
      Non-Max related

Maxunderground news unavailable

Nuke Python - Get viewport/DAG size
show user profile  br0t

I want to center my Nuke view on a group of nodes, zooming in exactly that much so that all nodes are visiblei in the view.

I have not found a way to get the current viewport size or similar though, which I need to calculate the correct zoom level :/

I know there is nuke.pan() and nuke.zoom() and I can get node positions and centers and such, but that bit is missing.

Any ideas? Can you even get that information?

never get low & slow & out of ideas

read 551 times
7/2/2014 10:30:12 AM (last edit: 7/2/2014 10:30:12 AM)
show user profile  reeves1984
You want to move the viewport during a script? Or is that the whole script, because you could just pres 'f' :)

these examples seem quite useful though?

Simon Reeves - VFX Artist & Blog
twitter <-- I work here

read 541 times
7/2/2014 12:04:17 PM (last edit: 7/2/2014 12:07:19 PM)
show user profile  br0t
Yes I know, I want that exact functionality, but not for the whole script, just a subset of it, e.g. my currently selected nodes.

Haha I did the most weird workaround now: I wrote a function decorator that before calling a function (which creates the bunch of nodes I want my view to zoom/fit to) will buffer and remove the whole scene, execute the function, zoom to fit ('f' basically), then recreate the buffered DAG afterwards.

Still wondering why that works :D Feels dangerous, but I just used it successfully on a very complex script with lots of expressions etc.
Nuke is really awesome in its possibility that you can simply copy a node tree and have it as text fully functional in the clipboard.

never get low & slow & out of ideas

read 532 times
7/2/2014 12:38:35 PM (last edit: 7/2/2014 12:40:09 PM)
show user profile  reeves1984
Heh that does sound scary but as you say.. just text so can't go too wrong you'd hope!

really helpful having ascii

I've made tools at work for all kinds of things, copy and paste over network, build nuke scripts with a text file rather than command line, useful!

Simon Reeves - VFX Artist & Blog
twitter <-- I work here

read 518 times
7/2/2014 3:04:05 PM (last edit: 7/2/2014 3:05:04 PM)
show user profile  br0t
Hm for some reason there is a problem though.

I have this giant node tree, that I buffer to a temp file and remove. Then I create a few hundred nodes based on some file. Afterwards I use nuke.scriptReadFile(...) to get back my old DAG.

For some reason it connects one of the new nodes with two of the nodes that come in with the restored DAG. Oo"

I have to finish my task today, so for now I will not use this hack :/

never get low & slow & out of ideas

read 497 times
7/2/2014 5:48:34 PM (last edit: 7/2/2014 5:48:54 PM)
#Maxforums IRC
Open chat window