3
$\begingroup$

I have a question. How can I access named custom instance attributes generated with Geometry Nodes in Python?

What I did:

  1. I set up named custom instance attribute with Geometry Nodes, named "Color"
  2. I confirmed that it's set expectedly in the Spread sheet
  3. I tried to access the "Color" instance attribute in python but I couldn't find the attribute

screenshot of setting up custon instance attribute with Geometry nodes

I iterated through evaluated instance objects, but I couldn't find.

depsgraph = bpy.context.evaluated_depsgraph_get()
for object_instance in depsgraph.object_instances:
    if object_instance.is_instance:
        for attr in dir(object_instance):
            print(str(attr), getattr(object_instance, attr))
        for attr in dir(object_instance.instance_object):
            print(str(attr), getattr(object_instance.instance_object, attr))
        for attr in dir(object_instance.object):
            print(str(attr), getattr(object_instance.object, attr))
        for attr in dir(object_instance.object.data):
            print(str(attr), getattr(object_instance.object.data, attr))

I thought it could be in object_instance.object.data.attributes, but it isn't in.

print(object_instance.object.data.attributes.keys())
["material_index", "uv_map"]

I'm happy if someone tells me how to access them.

Blender version: 3.3.1 OS: Windows 10

$\endgroup$
2
  • $\begingroup$ I'm interested in this too. As far as I get this attribute isn't in Object.data. It's somewhere in Object or ObjectInstance itself. $\endgroup$ Commented Dec 13, 2022 at 10:34
  • $\begingroup$ I just stick it here. blender.community/c/rightclickselect/k75r/?sorting=hot $\endgroup$ Commented Dec 13, 2022 at 15:44

1 Answer 1

0
$\begingroup$

In my case I solved the problem by storing the attribute Color on both the points and the instances created from the points and using Join Geometry.

Like this the Color attribute is accessible from the evaluated obj with obj_eval.data.attributes["Color"].

$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.