Jump to content

Callback Has To Import Everytime?


Atom

Recommended Posts

Hi All,

I am playing around with Python callback script for buttons. I place this code in the edit parameter interface.

exec(kwargs['node'].parm('python').eval());refreshValue(kwargs['node'].parm('my_slider').eval()) 

This does work. But from what I can tell, this means that each time I press the button the entire python text is evaluated. So if I have a 2000 line python script in my node but I only want to run a 2 line def the entire script has to be evaluated before that happens.

Is there any way around this?

As a programmer I imagined that once I type code into a python node it becomes a local module and I should be able to target defs inside it, somehow? But that does not seem to be the case. The text in my python node is just a string until an event happens which cooks the node. Does this mean my python code simply falls out of scope at the end of every cook/refresh?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...