Hello! Currently I am working on a Python Script that should get inputs from a modifier that is based on exposed Geometry nodes, and then create input buttons based on them.
The Problem:
I have my list from the Geometry nodes, however I cannot seem to get a proper Function Input Reference. I am using col.prop(insert reference area here, insert function input reference). And I just cannot seem to get it to work with procedurally created inputs. They don’t seem to exist anywhere that I can access.
Talking to a more experienced friend he said that modifiers of geometry nodes are an instance, so that could be why I am having so much trouble accessing them.
Has anyone else experienced this kind of thing before, or have any idea of what to do?
Thank you!
Here is the code. I have been trying to find a solution and messing with it a lot. It does have multiple classes, but these are really the only relevant ones currently. The For loop under Draw is the main place of the difficulty.
class My_Properties(bpy.types.PropertyGroup):
global list_of_variables
list_of_var = []
my_string : bpy.props.StringProperty(name= "Enter Text")
my_amount : bpy.props.IntProperty(name= "Amount", soft_min= 0, soft_max= 1000, default= 1)
#modifier = bpy.context.scene.objects.modifiers["GeometryNodes"]
'''for input in modifier.node_group.inputs:
input : bpy.props.IntProperty(name= input, soft_min= 0, soft_max= 1000, default= 1)
list_of_var.append(input.name)'''
def create_definitions(self, variable_name):
#exec(f'variable_name : bpy.props.IntProperty(name= variable_name, soft_min= 0, soft_max= 1000, default= 1)')
variable_name : bpy.props.IntProperty(name= variable_name, soft_min= 0, soft_max= 1000, default= 1)
return variable_name
#Creating a panel for the User Interface
class PROCEDURAL_PT_panel(bpy.types.Panel):
bl_label = "Procedural Item"
bl_idname = "PROCEDURAL_PT_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Procedural'
# Changable parameters
sliders_boolean = False
list_of_inputs = []
def draw(self, context):
layout = self.layout
scene = context.scene
mytool = scene.my_tool
global variables_generated
global list_of_variables
col = layout.column(align=True)
row = col.row(align=True)
col.operator(procedural.bl_idname, text = "Generate Object")
row = col.row(align=True)
amount_of_object = row.prop(mytool, "my_amount")
col = layout.column(align=True)
row = col.row(align=True)
col.operator(ui_def.bl_idname, text = "Generate Parameters")
modifier = bpy.context.active_object.modifiers["GeometryNodes"]
for input in modifier.node_group.inputs:
col.label(text=input.name)
input : bpy.props.IntProperty(name= input.name, soft_min= 0, soft_max= 1000, default= 1)
col.prop(modifier.node_group.inputs, input.name)
#Make these inputs
''' if(len(ui_def.input_list) > 0):
for a in ui_def.input_list:
if(variables_generated == False):
a : bpy.props.IntProperty(name= variable_name, soft_min= 0, soft_max= 1000, default= 1)
#list_of_variables.append(mytool.create_definitions(a))
#mytool.create_definitions(a)
row = col.row(align=True)
row.prop(self, a)
#row.prop(bpy.props, list_of_variables[0])
variables_generated = True
#row.prop(context.object, str(a), slider=True, text = str(a))
#self.list_of_inputs.append(a)'''
def invoke(self, context):
player_input = bpy.props.FloatProperty(name = "Enter Text:", default = 1)
return player_input
#Registering Classes
classes = (
PROCEDURAL_PT_panel,
procedural,
ui_def,
My_Properties
)
def register():
"""Register classes, properties"""
for cls in classes:
utils.make_annotations(cls)
bpy.utils.register_class(cls)
bpy.types.Scene.my_tool = bpy.props.PointerProperty(type= My_Properties)
def unregister():
"""Unregister classes, properties"""
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
del bpy.types.Scene.my_tool
if __name__ == "__main__":
register()