Jump to content

Python from string parameter


Drughi

Recommended Posts

16 hours ago, Alain2131 said:

See this
The eval() function is what you are looking for


stringCode = node.parm("someCodeParm").eval()
eval(stringCode) 

As for calling this code when pressing a button, is this inside an HDA ?

Ok, so now my Buttons callback script is: eval(kwargs['node'].parm('python').eval())

I've set the Python code string Tags to script_callback_language: python and editorlang: python.

Just for testing I've just added: print "Yeay, it worked"

But I'm getting the error:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SyntaxError: ('invalid syntax', ('<string>', 1, 5, 'print "Yeay, it worked"'))

What am I doing wrong?

Edited by Drughi
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...