Post #4783: In the previously discussed approach, the same value is set for all selected obj

📋 Metadata

🏷️ Tags

macro scripting advanced solved

  • Macro Editor
  • Python Scripting

💬 Content

In the previously discussed approach, the same value is set for all selected objects. However, to cater to situations that require more delicate editing, I propose a new approach that enables relative changes.

In the following method, changes in transparency are determined based on the rate of change in the active object:

# Getter
return C.active_object.color[3] if C.active_object and hasattr(C.active_object, 'color') else 0.0

# Setter
old_value = C.active_object.color[3]; C.active_object.color[3] = value; ratio = value / old_value if old_value != 0 else 0; [setattr(o, 'color', (*o.color[:3], max(0.0, min(1.0, o.color[3] * ratio)))) for o in C.selected_objects if o != C.active_object and hasattr(o, 'color')]

In the next method, changes in transparency are uniformly based on the change amount (difference) in the transparency of the active object:

# Getter
return C.active_object.color[3] if C.active_object and hasattr(C.active_object, 'color') else 0.0

# Setter
old_value = C.active_object.color[3]; C.active_object.color[3] = value; delta = value - old_value; [setattr(o, 'color', (*o.color[:3], max(0.0, min(1.0, o.color[3] + delta)))) for o in C.selected_objects if o != C.active_object and hasattr(o, 'color')]

❤️ 2 likes


🔗 View on Blender Artists