Skip to content

Instantly share code, notes, and snippets.

@zeffii
Forked from anonymous/node_Script.py
Created May 6, 2014 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/79af0505ee4c479c1ce1 to your computer and use it in GitHub Desktop.
Save zeffii/79af0505ee4c479c1ce1 to your computer and use it in GitHub Desktop.
dynamic props
if socket_type:
if stype == 's':
prop_type = None
if isinstance(dval, float):
prop_type = "bpy.props.FloatProperty"
elif isinstance(dval, int):
prop_type = "bpy.props.IntProperty"
if prop_type:
name_no_spaces = name.replace(" ", "_")
pname = "name='{0}', "
pdescription = "description='{0}', "
pdefault = "default={2}, "
options = "update=updateNode"
paramlist = pname + pdescription + pdefault + options
full_prop = '{0}_ = {1}(' + paramlist + ')'
full_prop = full_prop.format(name_no_spaces, prop_type, dval)
print(full_prop)
exec(full_prop)
node.inputs.new(socket_type, name, name).prop_name = name_no_spaces+'_'
return
node.inputs.new(socket_type, name, name).default = dval
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment