I think John specifically wanted to make this work in a terminal session.
And for the knobs to be populated correctly in a terminal session, you'll
need to use .forceValidate(), I believe.

John, can you post an example of what's not working for you?

The technique I mentioned before seems to work for me in a nuke -t session.
Ex:

>>> cam = nuke.createNode('Camera2', 'file /path/to/cam.fbx read_from_file
True')

# If you need to populate the fbx node names, then call cam.forceValidate()
here
# If you already know what they should be, then just set the values

>>> cam['fbx_take_name'].setValue('Take 001')
>>> cam['fbx_node_name'].setValue('camera1')

# At this point, the knobs won't be filled in, and will have the default
values as you described

>>> cam['focal'].value(), cam['transform'].value()
(50.0, {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1})  # camera defafults

# But if you call cam.forceValidate(), it should populate them
>>> cam.forceValidate()
>>> cam['focal'].value(), cam['transform'].value()
(21.354494094848633, {1, 0, 0, 0, 0, 0.970598, -0.240708, 0, 0, 0.240708,
0.970598, 0, 0, 71.3, 287.5, 1})


Is the above not working for you? Maybe make sure you're asking for the
knob values on the right frame. Keep in mind that, on a terminal session,
you start on frame 0.

Hope that helps.

Cheers,
Ivan


On Mon, May 7, 2012 at 9:34 AM, Micah Henrie <[email protected]> wrote:

> 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
>
> ------------------------------
> *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:
>
>  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:
>
> 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:
>
>> 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
>
>
>
>
> _______________________________________________
> 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

Reply via email to