I'm sure I'm not the only one who is a bit annoyed at the current workflow for applying the scale of multi-user objects. We first need to make one copy unique, then apply the scale for that, then re-link the other copies back to that object and hit alt+s to apply their scale values. This can get especially tedious, if the scene has multiple different object types with linked duplicates.
Could we write a script that loops through each object in the scene, and applies their scale if it's not already 1,1,1? And if the script encounters an object with linked duplicates, then it should make one copy unique, apply the scale and then relink everything back like it was before.
I asked chat GPT to write such a script and here's what it came up with. Are we anywhere close for this actually working?
import bpy
# Loop through all objects in the scene
for obj in bpy.context.scene.objects:
# Check if the object has a scale other than 1
if obj.scale != (1, 1, 1):
# Check if the object has a data block associated with it
if obj.data is not None:
# Check if the object is a linked duplicate
if obj.data.is_library_indirect:
# Make the linked duplicate a single user
obj.data = obj.data.copy()
# Apply the scale to the object
bpy.ops.object.transform_apply(scale=True)
# If the object was a linked duplicate, relink its object data
if obj.data.is_library_indirect:
obj.data = obj.data.library.remap_data(obj.data)