Have you tried using your PythonPanel subclass the same way you’re using the 
simple Panel, as opposed to encapsulating your node creation code in the class 
itself?

-Nathan



From: Simon Björk 
Sent: Sunday, November 04, 2012 11:04 AM
To: Nuke Python discussion 
Subject: [Nuke-python] Import fbx via PythonPanel

I'm trying to import an fbx file using a PythonPanel, but for some reason it 
doesn't work. Using forceValidate() the camera loads, but it doesn't set 
animation, focal etc. Strange thing is it works perfectly if I use a simple 
panel istead (I don't even have to use forceValidate()). Anyone have any idea 
why this is? I've found old treads where people had problems loading an fbx 
from a terminal session.

Example code PythonPanel (does not work):

class import_camera(nukescripts.PythonPanel):
    def __init__(self):
        nukescripts.PythonPanel.__init__(self, 'import camera')
        self.import_camera = nuke.PyScript_Knob("import_camera", "import 
camera")
        self.addKnob(self.import_camera)

    def knobChanged(self, knob):
        if knob is self.import_camera:

            filepath = "C:/Users/Simon/Desktop/A018_C001_05075H_baked.fbx"
            cam_name = "Camera_A018_C001_05075H"

            c = nuke.createNode('Camera2', 'file "%s"  read_from_file True'  % 
filepath)
            c.forceValidate()
            c["fbx_take_name"].setValue("Take 001")
            c["fbx_node_name"].setValue(cam_name)

import_camera().show()

Example code simple panel (works):

p = nuke.Panel("import camera")
result = p.show()
if result:

    filepath = "C:/Users/Simon/Desktop/A018_C001_05075H_baked.fbx"
    cam_name = "Camera_A018_C001_05075H"

    c = nuke.createNode('Camera2', 'file "%s"  read_from_file True'  % filepath)
    c["fbx_take_name"].setValue("Take 001")
    c["fbx_node_name"].setValue(cam_name)

Cheers,
Simon


--------------------------------------------------------------------------------
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to