You would need to read back your stored JSON object, append to it, and then 
replace the knob’s value with the updated version.

-Nathan



From: pexproduction 
Sent: Friday, August 24, 2012 1:59 PM
To: [email protected] 
Subject: [Nuke-python] JSON and knob Values storage....

Hello everyone,
i'm trying to storage the values of knobs added dinamically, to a JSON string 
in a global text knob. When i close and reopen the nuke script how can i add 
elements to it without resetting the json string???

thanks,
Mario


      Code:  
      import nuke
      import json

      i = """ + str(i) + """

      class TabsDialog(nukescripts.PythonPanel):
      def __init__(self): 
        super( TabsDialog, self ).__init__( "Options" ) 
        distance = nuke.Double_Knob("distance_" + str(i),"Distance")
        self.addKnob(distance)
        
      def knobChanged(self,knob):
        container = nuke.toNode("Prime_Flare.storage")['storage']
        if nuke.thisKnob().name() == "distance_" + str(i):
         x = nuke.thisKnob().value()
         b = nuke.toNode("Prime_Flare.transform_node_" + str(i))
         b['translate'].setExpression("((parent.Flare1.position - 
parent.Flare3.position)*(" + str(x) + ")) + (parent.Flare3.position)-1024")
         store = {}
         store['distance_' + str(i)] = x
         container.setValue(json.push(store))

      TabsDialog().showModalDialog()  



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