Blender Asked on December 16, 2021
I’m trying to determine if an object is a linked duplicate in a script.
My test scene is as simple as possible, 2 cubes, one a linked duplicate of another.
The following I have tried to no avail:
bpy.data.objects["Cube.001"].library (returns None)
bpy.data.objects["Cube.001"].original (returns "Cube.001")
bpy.data.objects["Cube.001"].is_property_set("linked")
(fails to run)I attempted to grep around in the source code to find a solution but I, unfortunately, couldn’t find anything that worked.
Object.data
Linked duplicates will have the same linked data, if there is linked data. For an empty ob.data is None
import bpy
from collections import defaultdict
scene = bpy.context.scene
data_links = defaultdict(list)
for ob in scene.objects:
data_links[ob.data].append(ob)
for k, v in data_links.items():
print(k, v)
Sample output, notice there are 4 objects using the mesh "Cube.001"
<bpy_struct, Mesh("Cube.001")> [bpy.data.objects['Cube'], bpy.data.objects['Cube.001'], bpy.data.objects['Cube.002'], bpy.data.objects['Cube.003']]
<bpy_struct, PointLight("Lamp")> [bpy.data.objects['Lamp']]
<bpy_struct, Camera("Camera")> [bpy.data.objects['Camera']]
None [bpy.data.objects['Empty'], bpy.data.objects['Field']]
Answered by batFINGER on December 16, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP