This works for me in 6.3v6--no forceValidate for what it is worth.... 

def loadCameraFbx(fbxPath, name='render_cam', fbxNode=None): 
""" 
Create a camera node and read in C{fbxPath} 
""" 
if not os.path.isfile(fbxPath): 
print 'Could not find %s; unable to load camera' % fbxPath 
return 

# create camera node 
camNode = nuke.createNode('Camera2', 'file "%s" read_from_file True' % fbxPath) 
camNode.setName(name) 
camNode['fbx_take_name'].setValue('Take 001') 

if fbxNode: 
camNode.knob('fbx_node_name').setValue(fbxNode) 

print 'Created camera "%s" from %s; node: %s' % (camNode.name(), fbxPath, 
fbxNode) 
return camNode 

----- Original Message -----

From: "John RA Benson" <[email protected]> 
Cc: "Nuke Python discussion" <[email protected]> 
Sent: Monday, May 7, 2012 4:12:39 AM 
Subject: Re: [Nuke-python] reading a camera fbx file in a terminal session? 

Has anyone managed to load an fbx camera via a script or terminal mode? 

thanks 
JRAB 

John RA Benson wrote: 

Ok, now that I'm back at the studio and trying to actually make this thing 
work: 


camera.forceValidate() seems to load the file, but not really. I get the 
fbx_take_name and fbx_node_name lists from the file, but if I set them, nothing 
happens. The lens is incorrect, matrix and translations not set, etc. Even 
after doing a camera.forceValidate() after each operation. 


Using the same commands in the GUI works fine. 


Any other ideas? 


jrab 





On Apr 21, 2012, at 10:28 AM, John RA Benson wrote: 

<blockquote>

Fantastic! Yes, there's a lot of actions I need to do after that, but none 
would work unless the camera loaded. Pretty useful function to get the hash 
updated too. 


I really need to update my docs link to the 6.3x versions... 


Many many thanks!!! 
JRAB 




On Apr 20, 2012, at 7:24 PM, Ivan Busquets wrote: 

<blockquote>
Hi John, 

Try: 

camera = nuke.createNode('Camera2', 'read_from_file true file %s' % fbxfile) 
followed by: 
camera.forceValidate() 

You'll probably need to manually set the fbx_node_name knob to the actual 
camera you want as well. 

Hope that helps. 


On Fri, Apr 20, 2012 at 10:12 AM, John RA Benson < 
[email protected] > wrote: 

<blockquote>
Hey there - 

I'm trying to load an fbx file in a terminal session - trying to script an 
automatic process. I'm stumped at setting up my camera. 

> nuke -t 

fbxfile = '/path/to/fbxfile.fbx' 
camera = nuke.createNode('Camera2') 
camera['read_from_file'].setValue(True) 
camera['file'].setValue(fbxfile) 

doesn't load it, neither does 

camera = nuke.createNode('Camera2', 'read_from_file true file %s' % fbxfile) 

The file knob is set, but it's not loaded so I can't really do much after that. 
Any ideas? 
Both of those work from the GUI, but the idea is to run this in a script. 

Thanks 
JRAB 
_______________________________________________ 
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 

</blockquote>


</blockquote>


</blockquote>

_______________________________________________ 
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