mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
blenderbim, bcf - add tooltips for topic attributes based on extensions
Example - https://imgur.com/a/mYiXqXn
This commit is contained in:
@@ -30,6 +30,10 @@ from bpy.props import (
|
|||||||
FloatVectorProperty,
|
FloatVectorProperty,
|
||||||
CollectionProperty,
|
CollectionProperty,
|
||||||
)
|
)
|
||||||
|
from functools import partial
|
||||||
|
from typing import Literal
|
||||||
|
from typing_extensions import assert_never
|
||||||
|
from bcf.agnostic.extensions import get_extensions_attributes
|
||||||
|
|
||||||
|
|
||||||
bcfviewpoints_enum = None
|
bcfviewpoints_enum = None
|
||||||
@@ -85,7 +89,11 @@ class BcfReferenceLink(PropertyGroup):
|
|||||||
|
|
||||||
|
|
||||||
class BcfLabel(PropertyGroup):
|
class BcfLabel(PropertyGroup):
|
||||||
name: StringProperty(name="Name", update=updateBcfLabel)
|
name: StringProperty(
|
||||||
|
name="Name",
|
||||||
|
update=updateBcfLabel,
|
||||||
|
search=lambda s, c, t: get_extensions_items(s, c, t, extensions_attr="topic_labels"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def getBcfViewpoints(self, context, force_update=False):
|
def getBcfViewpoints(self, context, force_update=False):
|
||||||
@@ -125,18 +133,48 @@ class BcfComment(PropertyGroup):
|
|||||||
is_editable: BoolProperty(name="Is Editable", default=False, update=updateBcfCommentIsEditable)
|
is_editable: BoolProperty(name="Is Editable", default=False, update=updateBcfCommentIsEditable)
|
||||||
|
|
||||||
|
|
||||||
|
def get_extensions_items(
|
||||||
|
self: "BCFProperties", context: bpy.types.Context, edit_text: str, extensions_attr: str
|
||||||
|
) -> list[str]:
|
||||||
|
bcf_file = bcfstore.BcfStore.get_bcfxml()
|
||||||
|
assert bcf_file
|
||||||
|
extensions = bcf_file.extensions
|
||||||
|
if extensions is None:
|
||||||
|
return []
|
||||||
|
|
||||||
|
extension_data = getattr(extensions, extensions_attr)
|
||||||
|
if extension_data is None:
|
||||||
|
return []
|
||||||
|
|
||||||
|
attrs = get_extensions_attributes(extensions)
|
||||||
|
attribute_data = attrs[extensions_attr]
|
||||||
|
return getattr(extension_data, attribute_data.subattr_name)
|
||||||
|
|
||||||
|
|
||||||
class BcfTopic(PropertyGroup):
|
class BcfTopic(PropertyGroup):
|
||||||
name: StringProperty(name="GUID")
|
name: StringProperty(name="GUID")
|
||||||
title: StringProperty(default="", name="Title", update=updateBcfTopicName)
|
title: StringProperty(default="", name="Title", update=updateBcfTopicName)
|
||||||
type: StringProperty(default="", name="Type")
|
type: StringProperty(
|
||||||
status: StringProperty(default="", name="Status")
|
default="", name="Type", search=lambda s, c, t: get_extensions_items(s, c, t, extensions_attr="topic_types")
|
||||||
priority: StringProperty(default="", name="Priority")
|
)
|
||||||
stage: StringProperty(default="", name="Stage")
|
status: StringProperty(
|
||||||
|
default="",
|
||||||
|
name="Status",
|
||||||
|
search=lambda s, c, t: get_extensions_items(s, c, t, extensions_attr="topic_statuses"),
|
||||||
|
)
|
||||||
|
priority: StringProperty(
|
||||||
|
default="", name="Priority", search=lambda s, c, t: get_extensions_items(s, c, t, extensions_attr="priorities")
|
||||||
|
)
|
||||||
|
stage: StringProperty(
|
||||||
|
default="", name="Stage", search=lambda s, c, t: get_extensions_items(s, c, t, extensions_attr="stages")
|
||||||
|
)
|
||||||
creation_date: StringProperty(default="", name="Date")
|
creation_date: StringProperty(default="", name="Date")
|
||||||
creation_author: StringProperty(default="", name="Author")
|
creation_author: StringProperty(default="", name="Author")
|
||||||
modified_date: StringProperty(default="", name="Modified Date")
|
modified_date: StringProperty(default="", name="Modified Date")
|
||||||
modified_author: StringProperty(default="", name="Modified By")
|
modified_author: StringProperty(default="", name="Modified By")
|
||||||
assigned_to: StringProperty(default="", name="Assigned To")
|
assigned_to: StringProperty(
|
||||||
|
default="", name="Assigned To", search=lambda s, c, t: get_extensions_items(s, c, t, extensions_attr="users")
|
||||||
|
)
|
||||||
due_date: StringProperty(default="", name="Due Date")
|
due_date: StringProperty(default="", name="Due Date")
|
||||||
description: StringProperty(default="", name="Topic Description")
|
description: StringProperty(default="", name="Topic Description")
|
||||||
viewpoints: EnumProperty(items=lambda _, context: getBcfViewpoints(_, context), name="BCF Viewpoints")
|
viewpoints: EnumProperty(items=lambda _, context: getBcfViewpoints(_, context), name="BCF Viewpoints")
|
||||||
@@ -163,7 +201,9 @@ class BCFProperties(PropertyGroup):
|
|||||||
reference_link: StringProperty(default="", name="Reference Link")
|
reference_link: StringProperty(default="", name="Reference Link")
|
||||||
label: StringProperty(default="", name="Label")
|
label: StringProperty(default="", name="Label")
|
||||||
bim_snippet_reference: StringProperty(default="", name="Reference")
|
bim_snippet_reference: StringProperty(default="", name="Reference")
|
||||||
bim_snippet_type: StringProperty(default="", name="Type")
|
bim_snippet_type: StringProperty(
|
||||||
|
default="", name="Type", search=lambda s, c, t: get_extensions_items(s, c, t, extensions_attr="snippet_types")
|
||||||
|
)
|
||||||
bim_snippet_schema: StringProperty(default="", name="Schema")
|
bim_snippet_schema: StringProperty(default="", name="Schema")
|
||||||
document_reference: StringProperty(default="", name="Referenced Document")
|
document_reference: StringProperty(default="", name="Referenced Document")
|
||||||
document_reference_description: StringProperty(default="", name="Description")
|
document_reference_description: StringProperty(default="", name="Description")
|
||||||
|
|||||||
@@ -78,18 +78,31 @@ class BIM_PT_bcf(Panel):
|
|||||||
row.operator("bim.remove_bcf_viewpoint", icon="X", text="")
|
row.operator("bim.remove_bcf_viewpoint", icon="X", text="")
|
||||||
|
|
||||||
col = layout.column(align=True)
|
col = layout.column(align=True)
|
||||||
props = ("type", "status", "priority", "stage", "assigned_to", "due_date")
|
topic_props = ("type", "status", "priority", "stage", "assigned_to", "due_date")
|
||||||
for prop in props:
|
bl_rna_props = topic.bl_rna.properties
|
||||||
|
|
||||||
|
def draw_prop(prop_name: str) -> None:
|
||||||
|
row = col.row(align=True)
|
||||||
|
row.label(text=f"{bl_rna_props[prop_name].name}")
|
||||||
|
row.label(text=getattr(topic, prop_name))
|
||||||
|
|
||||||
|
for prop in topic_props:
|
||||||
if getattr(topic, prop) or is_editable:
|
if getattr(topic, prop) or is_editable:
|
||||||
col.prop(topic, prop, emboss=is_editable)
|
# Can't just use emboss because search= on props is changing
|
||||||
|
# how they look and adds "ui.button_string_clear" button
|
||||||
|
# which allows clearing out the string and we don't want to.
|
||||||
|
if is_editable:
|
||||||
|
col.prop(topic, prop, emboss=is_editable)
|
||||||
|
else:
|
||||||
|
draw_prop(prop)
|
||||||
|
|
||||||
col = layout.column(align=True)
|
col = layout.column(align=True)
|
||||||
if topic.modified_date:
|
if topic.modified_date:
|
||||||
col.prop(topic, "modified_date", emboss=False)
|
draw_prop("modified_date")
|
||||||
col.prop(topic, "modified_author", emboss=False)
|
draw_prop("modified_author")
|
||||||
else:
|
else:
|
||||||
col.prop(topic, "creation_date", emboss=False)
|
draw_prop("creation_date")
|
||||||
col.prop(topic, "creation_author", emboss=False)
|
draw_prop("creation_author")
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_bcf_metadata(Panel):
|
class BIM_PT_bcf_metadata(Panel):
|
||||||
|
|||||||
Reference in New Issue
Block a user