Ah, yes, I re-read your last mail a couple of times and finally got it :).
It actually does work to do it that way, but that leaves me with the
default ok/cancel buttons and showModalDialog() instead of show(), correct?
Still seems strange that it gives different results.

Thanks Nathan!

Cheers,
Simon

2012/11/4 Nathan Rusch <nathan_ru...@hotmail.com>

>   Sorry, I probably should have been a little more clear. What I meant is
> basically using the GUI itself as a front-end for user input and
> confirmation only, and then gathering its values after the fact. Very
> simple example:
>
> class ImportCameraDialog(nukescripts.PythonPanel):
>     def __init__(self):
>         super(ImportCameraDialog, self).__init__('import camera')
>         self.fbxFile = ''
>         self.fbxFileKnob = nuke.File_Knob('fbx_path', 'fbx path')
>         self.addKnob(self.fbxFileKnob)
>
>     def knobChanged(self, knob):
>         if knob is self.fbxFileKnob:
>             self.fbxFile = self.fbxFileKnob.value()
>
>
> d = ImportCameraDialog()
> if d.showModalDialog():
>     fbxPath = d.fbxFile.strip()
>     if fbxPath:
>         # Validate path, create your node here, etc.
>         pass
>
>
> I don’t necessarily know if this will make a difference, but I think it’s
> worth a try.
>
> -Nathan
>
>
>  *From:* Simon Björk <bjork.si...@gmail.com>
> *Sent:* Sunday, November 04, 2012 1:35 PM
> *To:* Nuke Python discussion <nuke-python@support.thefoundry.co.uk>
> *Subject:* Re: [Nuke-python] Import fbx via PythonPanel
>
> Hi Nathan,
>
> thanks for your reply. I'm not really sure I understand how you mean, but
> I tried this and got the same results (not working).
>
>  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:
>             test()
>
> import_camera().show()
>
> def test():
>
>     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)
>
> Cheers,
> Simon
>
>
>
>
>
>
>
>
>
> 2012/11/4 Nathan Rusch <nathan_ru...@hotmail.com>
>
>>   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 <bjork.si...@gmail.com>
>> *Sent:* Sunday, November 04, 2012 11:04 AM
>> *To:* Nuke Python discussion <nuke-python@support.thefoundry.co.uk>
>> *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
>>
>>
>
> ------------------------------
> _______________________________________________
> 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
>
>
_______________________________________________
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