Thanks, Ivan. Will try this out Dev
On Sun, Aug 7, 2011 at 4:38 PM, Ivan Busquets <[email protected]>wrote: > Hi Dev! > > I believe the main problem is that an update of the knobs based on the > fbx content is only triggered by either a knobChanged event of the > file knob (which brings that prompt with it), or at the knob > construction stage (for which you'd need a new node, or a copy of it, > or re-opening the script) > > You can do what Nathan suggested and then rebuild any knobs you want > to preserve from your existing camera. > But if your camera has custom knobs and you need a more > "modify-the-existing-node-in-place" kind of approach, here's some bits > of a script I wrote a while back to get around the same problem you're > describing. > It's a bit of a hack, and there may be methods now to make this > simpler, but this used to work fine for this one purpose. > > ######### > def forceNodeConstructor(node): > """ Hack to force a node's constructor > by creating a new instance of the same node to replace it. > > """ > nodeName = node.name() > nodePos = (node.xpos(), node.ypos()) > selection = nuke.selectedNodes() > > nukescripts.clear_selection_recursive() > node.setSelected(True) > nukescripts.node_copypaste() > newNode = nuke.selectedNode() > > # connect inputs > for i in range(node.inputs()): > newNode.setInput(i, node.input(i)) > > # connect outputs > for d in node.dependent(nuke.INPUTS | nuke.HIDDEN_INPUTS): > for input in [i for i in range(d.inputs()) if d.input(i) == node]: > d.setInput(input,newNode) > > #Restore original selection > nukescripts.clear_selection_recursive() > if node in selection: selection[selection.index(node)] = newNode > for n in selection: > n.setSelected(True) > > # Delete original and copy name and position to new node > nuke.delete(node) > newNode.setName(nodeName) > newNode.setXYpos(nodePos[0], nodePos[1]) > > return newNode > > ########## > > # The "hack" is to use the above function to create a copy of your > camera AFTER you've changed the file knob, so the new copy will fill > in the fbx_take_name and fbx_node_name knobs using the new fbx file. > > cam = nuke.toNode('yourCameraName') > > # temporarily disable knobChanged on the file knob, so you won't > trigger the prompt if a user has the properties of that camera open > cam['file'].setFlag(0x00020000) # NO_KNOB_CHANGED flag > > # set the path of your FBX file > cam['file'].setValue(path_to_your_new_FBX_file) > > # clear the NO_KNOB_CHANGED flag > cam['file'].clearFlag(0x00020000) > > # create a new instance of your camera node now that the file path is > changed > newCam = forceNodeConstructor(cam) > > # open the Properties Pane so the Take and Node knobs get populated > newCam.showControlPanel() > > # set the fbx_take_name and fbx_node_name knobs if you already know > what they should be > newCam['fbx_take_name'].setValue('Take Name') > newCam['fbx_node_name'].setValue('Node Name') > > > Hope that makes sense. If there is a more straightforward / less hacky > approach, I'd be interested in knowing too. > (Nathan, come to the rescue) :) > > Cheers, > Ivan > > > On Fri, Aug 5, 2011 at 6:47 PM, Nathan Rusch <[email protected]> > wrote: > > As far as replacing an existing file, I’m not sure (haven’t played with > it > > much), but if you create the node using a call like this > > > > nuke.createNode('Camera2', 'name myNode file /path/to/file.fbx > > read_from_file true’) > > > > you can avoid the dialog the first time around. Not sure if re-creating > and > > swapping out the node every time is an option for you though. I may spend > > some time playing with it to see if there’s another way. > > > > -Nathan > > > > > > From: devMannemela > > Sent: Friday, August 05, 2011 6:15 PM > > To: [email protected] > > Subject: [Nuke-python] User prompt when updating camera node > > > > Hi ! > > > > How does one turn off the user prompts when updating a camera node ? > > > > I would like to change the file that an existing camera node reads. and > > update the fbx_node_name. > > > > cam = nuke.selectedNode() > > cam.showControlPanel() > > cam['file'].setValue(fbxCameraPath) > > cam['fbx_node_name'].setValue('shotCamera') > > > > > > This code works fine, but prompts the dialog "Are you sure you want to > read > > the camera from file....?". > > > > Is there a way to set the file name and read it without this dialog ? > > > > thanks ! > > Dev > > > > ________________________________ > > _______________________________________________ > > 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 > > > > > _______________________________________________ > 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
