1
$\begingroup$

I have a file with many (1000+) objects/instances, many of which are duplicates.

To organize my project I want to split single and multi user objects.

How do I select all objects that are not single user / that are multi-user

$\endgroup$
2
  • $\begingroup$ with Shift L you can select all the objects that share the same object data but not all the other objects that share another object data, but maybe you can do what you want with a script? $\endgroup$
    – moonboots
    Commented Feb 15, 2023 at 15:13
  • $\begingroup$ Yeah I know about Shift L, but doing it that way would mean selecting each object and 'trying' with Shift L if they are multi-user or not. Maybe a script is the best solution.. but I'm not really proficient in Python :( $\endgroup$
    – Warner
    Commented Feb 15, 2023 at 15:31

1 Answer 1

3
$\begingroup$

You can try something like this

import bpy

user_map = bpy.data.user_map()

bpy.context.view_layer.objects.active = None
for obj in bpy.context.selectable_objects:
    obj.select_set(False)
    # selectable_objects_users = [o for o in user_map.get(obj.data) if isinstance(o, bpy.types.Object) and o in bpy.context.selectable_objects]
    objects_users = [o for o in user_map.get(obj.data) if isinstance(o, bpy.types.Object)]
    if len(objects_users) > 1:
        obj.select_set(True)
bpy.context.view_layer.objects.active = bpy.context.selected_objects[0]

Get the dictionary mapping of all data blocks with user_map

Traverse all objects (or selectable objects, depends on if you want to find all linked objects in the file or in your selection

If the dictionary mapping of the mesh contains more than one object, the mesh is linked, select the object.

You can optimise this by selecting all the objects after the if statement and removing the selected objects from the test pool, but I don't think you'll gain much time. Unless you have hundreds of thousands of object, in which case you probably shouldn't try selecting them :)

$\endgroup$
1
  • $\begingroup$ Perfect, that does exactly what it says on the tin. Thank you! $\endgroup$
    – Warner
    Commented Feb 15, 2023 at 17:00

You must log in to answer this question.

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