Package nukescripts :: Module viewsettingsprefs
[hide private]
[frames] | no frames]

Source Code for Module nukescripts.viewsettingsprefs

 1  import nuke 
 2   
3 -def onCreateRoot():
4 5 preferencesNode = nuke.toNode('preferences') 6 7 # This should only be done if the Root being created is the global root used 8 # in the DAG, *not* Root nodes created by Studio 9 root = nuke.thisRoot() 10 if root != nuke.root(): 11 return 12 13 isNewComp = not root['name'].getValue() 14 15 # Do not override the view-related knobs from the Preferences 16 # if they've been set from a user-defined template.nk 17 isNotFromUserTemplate = not root['set_by_user_template'].getValue() 18 if isNewComp and isNotFromUserTemplate: 19 for knob in ("views", "hero_view", "views_colours"): 20 # Check knobDefaults to see if the value has been set. If it has been set, then preferences should not override it. 21 if(nuke.knobDefault("Root."+knob) is None): 22 root.knob(knob).fromScript(preferencesNode.knob(knob).toScript())
23 24 25 nuke.addOnCreate(onCreateRoot, nodeClass='Root') 26