Jump to content

Python: OnInputChanged Double eval?


Shalinar

Recommended Posts

Has anyone else encountered an issue with an hda python module where the OnInputChanged evaluates twice? I'm not sure what's causing it... Even simple code in the module triggers it -- eg:

node = kwargs['node']
print node

^ I get two printouts of the node each time i change the input connection.

I originally noticed this when I was trying to query the connected input. When I did

node = kwargs['node']
input = node.inputs()[0]
print input

I would get an error saying the index was out of the tuple range, followed by a correct printout of the first input connection. The first eval seems to trigger before the connection is actually made, hence why it errors the first time through. Then the second eval triggers once it's connected. This is bizarre, and I haven't yet figured out what's causing it. Surely this isn't standard behavior.

Anyone else seen this or have ideas as to what's causing it?

Thanks,

 

Chris

Link to comment
Share on other sites

You can file a bug report to support@sidefx.com.

Or just protect against it.

try:
	node = kwargs['node']
	input = node.inputs()[0]
	can_continue = True
except:
	can_continue = False
if can_continue:
	print input

 

Link to comment
Share on other sites

1 hour ago, Atom said:

Or just protect against it.


try:
	node = kwargs['node']
	input = node.inputs()[0]
	can_continue = True
except:
	can_continue = False
if can_continue:
	print input

 

Thanks for getting back to me :) Try/except is exactly what I ended up doing

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