Advertisement
Dieton

Object_Name_Transfer.py

Feb 21st, 2024 (edited)
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. #transfers the of one object to another
  2. import bpy
  3.  
  4. def transfer_object_name(obj_source, obj_target):
  5.     # Check if both objects are valid
  6.     if obj_source and obj_target:
  7.         # Copy the name from the source to the target
  8.         obj_target.name = obj_source.name
  9.         print(f"Object name transferred from '{obj_source.name}' to '{obj_target.name}'.")
  10.     else:
  11.         print("Invalid objects provided.")
  12.  
  13. # Get the selected objects
  14. selected_objects = bpy.context.selected_objects
  15.  
  16. # Ensure two objects are selected
  17. if len(selected_objects) == 2:
  18.     object_a, object_b = selected_objects
  19.  
  20.     # Call the function to transfer object name
  21.     transfer_object_name(object_a, object_b)
  22. else:
  23.     print("Please select exactly two objects: 'Object A' and 'Object B'.")
  24.  
Tags: blender
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement