Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This operator will look at all selected objects and match the active UV layer to whatever is the currently active object is.
- # if the uv layer does not exist, it will remain the same.
- import bpy
- class OBJECT_OT_set_active_uv(bpy.types.Operator):
- """Tooltip"""
- bl_idname = "object.set_active_uv"
- bl_label = "Set Active UV to Match Active Object"
- @classmethod
- def poll(cls, context):
- return context.active_object is not None and hasattr(o, "data") and isinstance(o.data, bpy.types.Mesh)
- def execute(self, context):
- target_uv = [uv.name for uv in context.active_object.data.uv_layers if uv.active][0]
- for o in context.selected_objects:
- if hasattr(o, "data") and isinstance(o.data, bpy.types.Mesh):
- for key in o.data.uv_layers.keys():
- if key == target_uv:
- o.data.uv_layers[key].active = True
- break
- return {'FINISHED'}
- def register():
- bpy.utils.register_class(OBJECT_OT_set_active_uv)
- def unregister():
- bpy.utils.unregister_class(OBJECT_OT_set_active_uv)
- if __name__ == "__main__":
- register()
Advertisement
Add Comment
Please, Sign In to add comment