0
$\begingroup$

I need to check which object is instanced at a certain location. The particle system spawns a collection of objects either as is or with the “Use Count” feature.

At the moment I found a way to get the locations with animation nodes, but couldn’t find a way to find out which of the collection objects is being spawned at that location.

enter image description here

Mabye there is a way to do it in python?

Thanks for the help!

This question is asociated with another question of mine: How to get same hair particles from collection in second particle system/ or how to delete instanced particles without converting them to real meshes?

$\endgroup$
1
$\begingroup$

Found a python solution to get all the instances in the depsgraph. By filtering with "is_instance" you can get the names of the instance object that corespond with the source objects.

import bpy

context = bpy.context

dg = context.evaluated_depsgraph_get()

counter = 0
for i in dg.object_instances:
    obj = i.object
    print(obj.name)
    if not i.is_instance:
        print(f"Object {obj.name} at {i.matrix_world}")
    else:
        print(f"Instance of {obj.name} at {i.matrix_world}")
        counter += 1
print(f"Len of instanced objects: {counter}")

enter image description here enter image description here

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.