Import fbx camera

importFbxCamera.py

Import fbx camera script will add a camera node and import the camera data from the fbx file based on selected "ReadGeo" node.

Usually we import our objects into nuke as a .fbx file. After importing the .fbx file will do the same thing for import the camera from the same file.  To do that go to toolbar-->3D-->Camera... check the "read from the file" and then import the .fbx file by clicking file browser.

To get reduce the above timing. I created this small "importFbxCamera" python script. 

Import your object files by "ReadGeo" node in nuke. Select the "ReadGeo" node and run this script.


It will automatically create a "camera" node and import the camera data from the .fbx file and create a backdrop with shot name.



If you have not selected any nodes this script will show a message...
   "select ReadGeo node to import camera"



Result:

Your camera will imported into nuke with name.



importFbxCamera.py:

import nuke
import nukescripts
def importFbxCamera():
    a = None
    try:
     a = nuke.selectedNode()
    except ValueError: # no node selected
        pass

    if a is not None:
        path =a.knob('file').value()
        s = path.split('/')[-1]
        x = s.split('.')[-0]
        name = x + ('_Camera')
        d = a.xpos() + 250
        c = nuke.createNode("Camera2")
        c.setName(name)
        c['xpos'].setValue(d)
        c['read_from_file'].setValue(1)
        c['file'].setValue(path)
        b = nukescripts.autoBackdrop().setName(name)
    else:
        nuke.message('select ReadGeo node to import camera')

add these lines into your menu.py
n = nuke.toolbar('Nodes')
n.addCommand('Test/importFbxCamera', 'importFbxCamera.importFbxCamera()')

Popular posts from this blog

2D Volumetric rays in nuke

Nuke workFlow optimisation TIPS

Export Maya camera and Objects to Nuke