Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit 05d8354

Browse files
committed
Reimplement basic BCF metadata editing and further improve BCF UI
1 parent 03d8537 commit 05d8354

4 files changed

Lines changed: 201 additions & 85 deletions

File tree

src/ifcblenderexport/blenderbim/bim/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
operator.LoadBcfProject,
3030
operator.LoadBcfTopics,
3131
operator.LoadBcfComments,
32+
operator.EditBcfProjectName,
33+
operator.EditBcfAuthor,
34+
operator.EditBcfTopicName,
35+
operator.EditBcfTopic,
3236
operator.SaveBcfProject,
3337
operator.AddBcfTopic,
3438
operator.ViewBcfTopic,
@@ -297,6 +301,7 @@
297301
ui.BIM_PT_ifccsv,
298302
ui.BIM_PT_ifcclash,
299303
ui.BIM_PT_bcf,
304+
ui.BIM_PT_bcf_metadata,
300305
ui.BIM_PT_bcf_comments,
301306
ui.BIM_PT_owner,
302307
ui.BIM_PT_people,

src/ifcblenderexport/blenderbim/bim/operator.py

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,6 @@ def execute(self, context):
527527
bcfxml = bcfstore.BcfStore.get_bcfxml()
528528
if self.filepath:
529529
bcfxml.get_project(self.filepath)
530-
bpy.context.scene.BCFProperties.is_editable = False
531530
bpy.context.scene.BCFProperties.name = bcfxml.project.name
532531
bpy.ops.bim.load_bcf_topics()
533532
bpy.context.scene.BCFProperties.is_loaded = True
@@ -627,6 +626,64 @@ def execute(self, context):
627626
return {"FINISHED"}
628627

629628

629+
class EditBcfProjectName(bpy.types.Operator):
630+
bl_idname = "bim.edit_bcf_project_name"
631+
bl_label = "Edit BCF Project Name"
632+
633+
def execute(self, context):
634+
bcfxml = bcfstore.BcfStore.get_bcfxml()
635+
bcfxml.project.name = bpy.context.scene.BCFProperties.name
636+
bcfxml.edit_project()
637+
return {"FINISHED"}
638+
639+
640+
class EditBcfAuthor(bpy.types.Operator):
641+
bl_idname = "bim.edit_bcf_author"
642+
bl_label = "Edit BCF Author"
643+
644+
def execute(self, context):
645+
bcfxml = bcfstore.BcfStore.get_bcfxml()
646+
bcfxml.author = bpy.context.scene.BCFProperties.author
647+
return {"FINISHED"}
648+
649+
650+
class EditBcfTopicName(bpy.types.Operator):
651+
bl_idname = "bim.edit_bcf_topic_name"
652+
bl_label = "Edit BCF Topic Name"
653+
654+
def execute(self, context):
655+
props = bpy.context.scene.BCFProperties
656+
blender_topic = props.topics[props.active_topic_index]
657+
bcfxml = bcfstore.BcfStore.get_bcfxml()
658+
topic = bcfxml.topics[blender_topic.name]
659+
topic.title = blender_topic.title
660+
bcfxml.edit_topic(topic)
661+
return {"FINISHED"}
662+
663+
664+
class EditBcfTopic(bpy.types.Operator):
665+
bl_idname = "bim.edit_bcf_topic"
666+
bl_label = "Edit BCF Topic"
667+
668+
def execute(self, context):
669+
props = bpy.context.scene.BCFProperties
670+
blender_topic = props.topics[props.active_topic_index]
671+
bcfxml = bcfstore.BcfStore.get_bcfxml()
672+
673+
topic = bcfxml.topics[blender_topic.name]
674+
topic.title = blender_topic.title or None
675+
topic.priority = blender_topic.priority or None
676+
topic.due_date = blender_topic.due_date or None
677+
topic.assigned_to = blender_topic.assigned_to or None
678+
topic.stage = blender_topic.stage or None
679+
topic.description = blender_topic.description or None
680+
topic.topic_status = blender_topic.status or None
681+
topic.topic_type = blender_topic.type or None
682+
683+
bcfxml.edit_topic(topic)
684+
return {"FINISHED"}
685+
686+
630687
class SaveBcfProject(bpy.types.Operator):
631688
bl_idname = "bim.save_bcf_project"
632689
bl_label = "Save BCF Project"

src/ifcblenderexport/blenderbim/bim/prop.py

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,35 @@ def refreshFontSize(self, context):
540540
annotation.Annotator.resize_text(context.active_object)
541541

542542

543+
def updateBcfProjectName(self, context):
544+
bpy.ops.bim.edit_bcf_project_name()
545+
546+
547+
def updateBcfAuthor(self, context):
548+
bpy.ops.bim.edit_bcf_author()
549+
550+
551+
def updateBcfTopicName(self, context):
552+
bpy.ops.bim.edit_bcf_topic_name()
553+
554+
555+
def updateBcfTopicIsEditable(self, context):
556+
if not self.is_editable:
557+
print("EDITING!")
558+
bpy.ops.bim.edit_bcf_topic()
559+
560+
561+
def refreshBcfTopic(self, context):
562+
global bcfviewpoints_enum
563+
bcfviewpoints_enum = None
564+
565+
props = bpy.context.scene.BCFProperties
566+
bcfxml = bcfstore.BcfStore.get_bcfxml()
567+
topic = props.topics[props.active_topic_index]
568+
header = bcfxml.get_header(topic.name)
569+
getBcfViewpoints(self, context)
570+
571+
543572
class StrProperty(PropertyGroup):
544573
pass
545574

@@ -948,7 +977,7 @@ class BcfComment(PropertyGroup):
948977

949978
class BcfTopic(PropertyGroup):
950979
name: StringProperty(name="GUID")
951-
title: StringProperty(default="", name="Title")
980+
title: StringProperty(default="", name="Title", update=updateBcfTopicName)
952981
type: StringProperty(default="", name="Type")
953982
status: StringProperty(default="", name="Status")
954983
priority: StringProperty(default="", name="Priority")
@@ -968,17 +997,7 @@ class BcfTopic(PropertyGroup):
968997
document_references: CollectionProperty(name="Document References", type=BcfDocumentReference)
969998
related_topics: CollectionProperty(name="Related Topics", type=StrProperty)
970999
comments: CollectionProperty(name="Comments", type=BcfComment)
971-
972-
973-
def refreshBcfTopic(self, context):
974-
global bcfviewpoints_enum
975-
bcfviewpoints_enum = None
976-
977-
props = bpy.context.scene.BCFProperties
978-
bcfxml = bcfstore.BcfStore.get_bcfxml()
979-
topic = props.topics[props.active_topic_index]
980-
header = bcfxml.get_header(topic.name)
981-
getBcfViewpoints(self, context)
1000+
is_editable: BoolProperty(name="Is Editable", default=False, update=updateBcfTopicIsEditable)
9821001

9831002

9841003
class PropertySetTemplate(PropertyGroup):
@@ -1487,11 +1506,10 @@ class BIMProperties(PropertyGroup):
14871506

14881507

14891508
class BCFProperties(PropertyGroup):
1490-
is_editable: BoolProperty(name="Is Editable", default=False)
14911509
is_loaded: BoolProperty(name="Is Loaded", default=False)
14921510
comment_text_width: IntProperty(name="Comment Text Width", default=40)
1493-
name: StringProperty(default="", name="Project Name")
1494-
author: StringProperty(default="john@doe.com", name="Author Email")
1511+
name: StringProperty(default="", name="Project Name", update=updateBcfProjectName)
1512+
author: StringProperty(default="john@doe.com", name="Author Email", update=updateBcfAuthor)
14951513
topics: CollectionProperty(name="BCF Topics", type=BcfTopic)
14961514
active_topic_index: IntProperty(name="Active BCF Topic Index", update=refreshBcfTopic)
14971515

src/ifcblenderexport/blenderbim/bim/ui.py

Lines changed: 105 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,7 @@ class BIM_PT_bcf(Panel):
16581658
def draw(self, context):
16591659
layout = self.layout
16601660
layout.use_property_split = True
1661+
layout.use_property_decorate = False
16611662

16621663
scene = context.scene
16631664
props = bpy.context.scene.BCFProperties
@@ -1682,96 +1683,130 @@ def draw(self, context):
16821683
row.template_list("BIM_UL_topics", "", props, "topics", props, "active_topic_index")
16831684
col = row.column(align=True)
16841685
col.operator("bim.add_bcf_topic", icon="ADD", text="")
1686+
if props.active_topic_index < len(props.topics):
1687+
topic = props.topics[props.active_topic_index]
1688+
col.prop(topic, "is_editable", icon="CHECKMARK" if topic.is_editable else "GREASEPENCIL", icon_only=True)
16851689

16861690
if props.active_topic_index < len(props.topics):
16871691
topic = props.topics[props.active_topic_index]
16881692
row = layout.row()
1693+
row.enabled = topic.is_editable
16891694
row.prop(topic, "description", text="")
16901695

16911696
row = layout.row()
16921697
row.prop(topic, "viewpoints")
16931698
row.operator("bim.activate_bcf_viewpoint", icon="SCENE", text="")
16941699

16951700
col = layout.column(align=True)
1696-
col.prop(topic, "type")
1697-
col.prop(topic, "status")
1698-
col.prop(topic, "priority")
1699-
col.prop(topic, "stage")
1700-
col.prop(topic, "assigned_to")
1701-
col.prop(topic, "due_date")
1701+
if topic.type:
1702+
col.prop(topic, "type", emboss=topic.is_editable)
1703+
if topic.status:
1704+
col.prop(topic, "status", emboss=topic.is_editable)
1705+
if topic.priority:
1706+
col.prop(topic, "priority", emboss=topic.is_editable)
1707+
if topic.stage:
1708+
col.prop(topic, "stage", emboss=topic.is_editable)
1709+
if topic.assigned_to:
1710+
col.prop(topic, "assigned_to", emboss=topic.is_editable)
1711+
if topic.due_date:
1712+
col.prop(topic, "due_date", emboss=topic.is_editable)
17021713

17031714
col = layout.column(align=True)
1704-
col.enabled = False
1705-
col.prop(topic, "creation_date")
1706-
col.prop(topic, "creation_author")
1707-
col.prop(topic, "modified_date")
1708-
col.prop(topic, "modified_author")
1709-
1710-
bcfxml = bcfstore.BcfStore.get_bcfxml()
1711-
bcf_topic = bcfxml.topics[topic.name]
1712-
1713-
if bcf_topic.header:
1714-
layout.label(text="Header Files:")
1715-
for index, f in enumerate(bcf_topic.header.files):
1716-
box = self.layout.box()
1717-
row = box.row(align=True)
1718-
row.label(text=f.filename, icon="FILE_BLANK")
1719-
if f.is_external:
1720-
row.operator("bim.open_uri", icon="URL", text="").uri = f.reference
1721-
else:
1722-
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
1723-
op.uri = os.path.join(bcfxml.filepath, topic.name, f.reference)
1724-
box.label(text=f.date)
1725-
#box.label(text=f.ifc_project)
1726-
#box.label(text=f.ifc_spatial_structure_element)
1727-
1728-
if topic.reference_links:
1729-
layout.label(text="Reference Links:")
1730-
for index, link in enumerate(topic.reference_links):
1731-
row = layout.row(align=True)
1732-
row.prop(link, "name")
1733-
row.operator("bim.open_uri", icon="URL", text="").uri = link.name
1715+
if topic.modified_date:
1716+
col.prop(topic, "modified_date", emboss=False)
1717+
col.prop(topic, "modified_author", emboss=False)
1718+
else:
1719+
col.prop(topic, "creation_date", emboss=False)
1720+
col.prop(topic, "creation_author", emboss=False)
17341721

1735-
if topic.labels:
1736-
layout.label(text="Labels:")
1737-
for index, label in enumerate(topic.labels):
1738-
row = layout.row(align=True)
1739-
row.prop(label, "name", text="")
17401722

1741-
if topic.bim_snippet.schema:
1742-
layout.label(text="BIM Snippet:")
1723+
class BIM_PT_bcf_metadata(Panel):
1724+
bl_label = "BCF Metadata"
1725+
bl_idname = "BIM_PT_bcf_metadata"
1726+
bl_options = {"DEFAULT_CLOSED"}
1727+
bl_space_type = "PROPERTIES"
1728+
bl_region_type = "WINDOW"
1729+
bl_context = "scene"
1730+
bl_parent_id = "BIM_PT_bcf"
1731+
1732+
def draw(self, context):
1733+
layout = self.layout
1734+
layout.use_property_split = True
1735+
layout.use_property_decorate = False
1736+
1737+
scene = context.scene
1738+
props = bpy.context.scene.BCFProperties
1739+
1740+
if props.active_topic_index >= len(props.topics):
1741+
layout.label(text="No BCF project is loaded")
1742+
return
1743+
1744+
topic = props.topics[props.active_topic_index]
1745+
bcfxml = bcfstore.BcfStore.get_bcfxml()
1746+
bcf_topic = bcfxml.topics[topic.name]
1747+
1748+
if bcf_topic.header:
1749+
layout.label(text="Header Files:")
1750+
for index, f in enumerate(bcf_topic.header.files):
1751+
box = self.layout.box()
1752+
row = box.row(align=True)
1753+
row.label(text=f.filename, icon="FILE_BLANK")
1754+
if f.is_external:
1755+
row.operator("bim.open_uri", icon="URL", text="").uri = f.reference
1756+
else:
1757+
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
1758+
op.uri = os.path.join(bcfxml.filepath, topic.name, f.reference)
1759+
box.label(text=f.date)
1760+
#box.label(text=f.ifc_project)
1761+
#box.label(text=f.ifc_spatial_structure_element)
1762+
1763+
if topic.reference_links:
1764+
layout.label(text="Reference Links:")
1765+
for index, link in enumerate(topic.reference_links):
17431766
row = layout.row(align=True)
1744-
row.prop(topic.bim_snippet, "type")
1745-
if topic.bim_snippet.schema:
1746-
row.operator("bim.open_uri", icon="URL", text="").uri = topic.bim_snippet.schema
1767+
row.prop(link, "name")
1768+
row.operator("bim.open_uri", icon="URL", text="").uri = link.name
17471769

1770+
if topic.labels:
1771+
layout.label(text="Labels:")
1772+
for index, label in enumerate(topic.labels):
17481773
row = layout.row(align=True)
1749-
row.prop(topic.bim_snippet, "reference")
1750-
if topic.bim_snippet.is_external:
1751-
row.operator("bim.open_uri", icon="URL", text="").uri = topic.bim_snippet.reference
1774+
row.prop(label, "name", text="")
1775+
1776+
if topic.bim_snippet.schema:
1777+
layout.label(text="BIM Snippet:")
1778+
row = layout.row(align=True)
1779+
row.prop(topic.bim_snippet, "type")
1780+
if topic.bim_snippet.schema:
1781+
row.operator("bim.open_uri", icon="URL", text="").uri = topic.bim_snippet.schema
1782+
1783+
row = layout.row(align=True)
1784+
row.prop(topic.bim_snippet, "reference")
1785+
if topic.bim_snippet.is_external:
1786+
row.operator("bim.open_uri", icon="URL", text="").uri = topic.bim_snippet.reference
1787+
else:
1788+
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
1789+
op.uri = os.path.join(bcfxml.filepath, topic.name, topic.bim_snippet.reference)
1790+
1791+
if topic.document_references:
1792+
layout.label(text="Document References:")
1793+
for index, doc in enumerate(topic.document_references):
1794+
box = self.layout.box()
1795+
row = box.row(align=True)
1796+
row.prop(doc, "reference")
1797+
if doc.is_external:
1798+
row.operator("bim.open_uri", icon="URL", text="").uri = doc.reference
17521799
else:
17531800
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
1754-
op.uri = os.path.join(bcfxml.filepath, topic.name, topic.bim_snippet.reference)
1755-
1756-
if topic.document_references:
1757-
layout.label(text="Document References:")
1758-
for index, doc in enumerate(topic.document_references):
1759-
box = self.layout.box()
1760-
row = box.row(align=True)
1761-
row.prop(doc, "reference")
1762-
if doc.is_external:
1763-
row.operator("bim.open_uri", icon="URL", text="").uri = doc.reference
1764-
else:
1765-
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
1766-
op.uri = os.path.join(bcfxml.filepath, topic.name, doc.reference)
1767-
row = box.row(align=True)
1768-
row.prop(doc, "description")
1801+
op.uri = os.path.join(bcfxml.filepath, topic.name, doc.reference)
1802+
row = box.row(align=True)
1803+
row.prop(doc, "description")
17691804

1770-
if topic.related_topics:
1771-
layout.label(text="Related Topics:")
1772-
for related_topic in topic.related_topics:
1773-
row = layout.row(align=True)
1774-
row.operator("bim.view_bcf_topic", text=related_topic.name).topic_guid = related_topic.name
1805+
if topic.related_topics:
1806+
layout.label(text="Related Topics:")
1807+
for related_topic in topic.related_topics:
1808+
row = layout.row(align=True)
1809+
row.operator("bim.view_bcf_topic", text=related_topic.name).topic_guid = related_topic.name
17751810

17761811

17771812
class BIM_PT_bcf_comments(Panel):
@@ -1786,6 +1821,7 @@ class BIM_PT_bcf_comments(Panel):
17861821
def draw(self, context):
17871822
layout = self.layout
17881823
layout.use_property_split = True
1824+
layout.use_property_decorate = False
17891825

17901826
scene = context.scene
17911827
props = bpy.context.scene.BCFProperties

0 commit comments

Comments
 (0)