Bonsai Attribute to support copying it's name to clipboard #5892

Example - https://i.imgur.com/Jf1jofZ.png
This commit is contained in:
Andrej730
2024-12-20 19:39:28 +05:00
parent f7395ccd52
commit 1f68464d46
3 changed files with 20 additions and 2 deletions
+1
View File
@@ -105,6 +105,7 @@ classes = [
operator.ClippingPlaneCutWithCappings,
operator.CloseBlendWarning,
operator.CloseError,
operator.CopyTextToClipboard,
operator.EditBlenderCollection,
operator.FileAssociate,
operator.FileUnassociate,
+13
View File
@@ -1143,3 +1143,16 @@ class RevertClippingPlaneCut(bpy.types.Operator):
if replaced_mesh:
obj.data = replaced_mesh
tool.Blender.remove_data_block(mesh, do_unlink=False)
class CopyTextToClipboard(bpy.types.Operator):
bl_idname = "bim.copy_text_to_clipboard"
bl_label = "Copy Text To Clipboard"
bl_description = "Copy text to clipboard."
bl_options = set()
text: bpy.props.StringProperty(options={"SKIP_SAVE"})
def execute(self, context):
context.window_manager.clipboard = self.text
return {"FINISHED"}
+6 -2
View File
@@ -1122,7 +1122,7 @@ def draw_statusbar(self, context):
self.layout.label(text=text)
def draw_custom_context_menu(self, context):
def draw_custom_context_menu(self: bpy.types.Menu, context: bpy.types.Context) -> None:
# https://blender.stackexchange.com/a/275555/86891
if (
not hasattr(context, "button_pointer")
@@ -1150,12 +1150,16 @@ def draw_custom_context_menu(self, context):
url = doc.get("spec_url", "")
else: # It's a custom property set. No URL available
url = ""
attr_name = attr.name
if description:
layout.separator()
op_description = layout.operator("bim.show_description", text="IFC Description", icon="INFO")
op_description.attr_name = getattr(context.button_pointer, "name", "")
op_description.attr_name = attr_name
op_description.description = description
op_description.url = url
if attr_name:
op = layout.operator("bim.copy_text_to_clipboard", text="Copy Attribute Name", icon="COPYDOWN")
op.text = attr_name
else:
# Ugly but we can't know which type of data is under the cursor so we test everything until it clicks
try: