I came across this question and learned that I can actually expose properties from the Blender UI in my addon panel. So I was experimenting on exposing properties of modifiers like for example the thickness of the Solidify Modifier, I can do:

layout.prop(data=context.object.modifiers["Solidify"], property="thickness", text="Thickness")
layout.prop(data=context.scene.render,property="fps",text="Frame Rate")

So now I'm interested in exposing properties of Geometry Nodes modifiers but I can't get it to work.

enter image description here

I tried the following

layout.prop(data=context.object.modifiers["GeometryNodes"]["Socket_2"], property="My Attr", text="My Attribute")

which gives me the following error:

Traceback (most recent call last):
  File "C:\Users\harry\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\test\ui\sidebar_menu.py", line 111, in draw
    layout.prop(data=context.object.modifiers["GeometryNodes"]["Socket_2"], property="My Attr", text="My Attribute")
TypeError: UILayout.prop(): error with keyword argument "data" -  Function.data expected a AnyType type, not float

and then tried:

layout.prop(data=context.object.modifiers["GeometryNodes"], property="Socket_2", text="My Attribute")

which gives me error:

rna_uiItemR: property not found: NodesModifier.Socket_2

    C:\Users\harry\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\test\ui\sidebar_menu.py:111

Is what I'm looking for even possible?


1 Answer 1

md = context.object.modifiers["GeometryNodes"]
name = next(rna.name for rna in md.node_group.interface.items_tree if rna.identifier == "Socket_2")

layout.prop(data=md, property='["Socket_2"]', text=name)

enter image description here

import bpy

class OBJECT_PT_CustomPanel(bpy.types.Panel):
    bl_label = "Custom Panel"
    bl_idname = "OBJECT_PT_custom_panel"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"
    def draw(self, context):
        layout = self.layout
        layout.prop(data=bpy.context.scene.render,property="fps",text="Frame Rate")
        obj_name = "Cube"
        md_name = "GeometryNodes"
            layout.prop(data=bpy.data.objects[obj_name].modifiers[md_name], property='["Socket_2"]')

def register():

def unregister():

if __name__ == "__main__":

For Pointer Properties: Collection, Material, Texture, Image, Please visit Unable to Access exposed Material Input in Addon from Geometry Nodes Modifier

  • $\begingroup$ I added a thing to access the socket name, check it out. $\endgroup$
    – X Y
    Commented May 2 at 17:58
  • $\begingroup$ thank you. there is another question similar to this here but the material selection gets disabled. do you know why? $\endgroup$
    – Harry McKenzie
    Commented May 6 at 9:44
  • 1
    $\begingroup$ I posted a new answer to that post. $\endgroup$
    – X Y
    Commented May 6 at 12:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .