-
-
Save zeffii/79af0505ee4c479c1ce1 to your computer and use it in GitHub Desktop.
dynamic props
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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