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

Commit de4f18e

Browse files
committed
New UI to show BCF comments in the BCF panel as a subpanel
1 parent 85a78a6 commit de4f18e

4 files changed

Lines changed: 98 additions & 11 deletions

File tree

src/ifcblenderexport/blenderbim/bim/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
operator.NewBcfProject,
2929
operator.LoadBcfProject,
3030
operator.LoadBcfTopics,
31+
operator.LoadBcfComments,
3132
operator.SaveBcfProject,
3233
operator.AddBcfTopic,
3334
operator.ViewBcfTopic,
@@ -260,6 +261,7 @@
260261
prop.Sheet,
261262
prop.BcfBimSnippet,
262263
prop.BcfDocumentReference,
264+
prop.BcfComment,
263265
prop.BcfTopic,
264266
prop.Subcontext,
265267
prop.PresentationLayer,
@@ -295,6 +297,7 @@
295297
ui.BIM_PT_ifccsv,
296298
ui.BIM_PT_ifcclash,
297299
ui.BIM_PT_bcf,
300+
ui.BIM_PT_bcf_comments,
298301
ui.BIM_PT_owner,
299302
ui.BIM_PT_people,
300303
ui.BIM_PT_organisations,

src/ifcblenderexport/blenderbim/bim/operator.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,8 @@ def execute(self, context):
550550
for topic in bcfxml.topics.values():
551551
new = bpy.context.scene.BCFProperties.topics.add()
552552
data_map = {
553-
"name": topic.title,
554-
"guid": topic.guid,
553+
"name": topic.guid,
554+
"title": topic.title,
555555
"type": topic.topic_type,
556556
"status": topic.topic_status,
557557
"priority": topic.priority,
@@ -597,6 +597,33 @@ def execute(self, context):
597597
for related_topic in topic.related_topics:
598598
new2 = new.related_topics.add()
599599
new2.name = related_topic.guid
600+
bpy.ops.bim.load_bcf_comments(topic_guid = topic.guid)
601+
return {"FINISHED"}
602+
603+
604+
class LoadBcfComments(bpy.types.Operator):
605+
bl_idname = "bim.load_bcf_comments"
606+
bl_label = "Load BCF Comments"
607+
topic_guid: bpy.props.StringProperty()
608+
609+
def execute(self, context):
610+
bcfxml = bcfstore.BcfStore.get_bcfxml()
611+
bcfxml.get_comments(self.topic_guid)
612+
blender_topic = bpy.context.scene.BCFProperties.topics.get(self.topic_guid)
613+
for comment in bcfxml.topics[self.topic_guid].comments.values():
614+
new = blender_topic.comments.add()
615+
data_map = {
616+
"name": comment.guid,
617+
"comment": comment.comment,
618+
"viewpoint": comment.viewpoint.guid if comment.viewpoint else None,
619+
"date": comment.date,
620+
"author": comment.author,
621+
"modified_date": comment.modified_date,
622+
"modified_author": comment.modified_author,
623+
}
624+
for key, value in data_map.items():
625+
if value is not None:
626+
setattr(new, key, str(value))
600627
return {"FINISHED"}
601628

602629

src/ifcblenderexport/blenderbim/bim/prop.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ def getBcfViewpoints(self, context):
917917
props = bpy.context.scene.BCFProperties
918918
bcfxml = bcfstore.BcfStore.get_bcfxml()
919919
topic = props.topics[props.active_topic_index]
920-
viewpoints = bcfxml.get_viewpoints(topic.guid)
920+
viewpoints = bcfxml.get_viewpoints(topic.name)
921921
bcfviewpoints_enum.extend([(v, f"Viewpoint {i+1}", "") for i, v in enumerate(viewpoints.keys())])
922922
return bcfviewpoints_enum
923923

@@ -936,9 +936,19 @@ class BcfDocumentReference(PropertyGroup):
936936
is_external: BoolProperty(name="Is External")
937937

938938

939+
class BcfComment(PropertyGroup):
940+
name: StringProperty(name="GUID")
941+
date: StringProperty(name="Date")
942+
author: StringProperty(name="Author")
943+
comment: StringProperty(name="Comment")
944+
viewpoint: StringProperty(name="Viewpoint")
945+
modified_date: StringProperty(name="Modified Date")
946+
modified_author: StringProperty(name="Modified Author")
947+
948+
939949
class BcfTopic(PropertyGroup):
940-
name: StringProperty(name="Name")
941-
guid: StringProperty(default="", name="GUID")
950+
name: StringProperty(name="GUID")
951+
title: StringProperty(default="", name="Title")
942952
type: StringProperty(default="", name="Type")
943953
status: StringProperty(default="", name="Status")
944954
priority: StringProperty(default="", name="Priority")
@@ -957,6 +967,7 @@ class BcfTopic(PropertyGroup):
957967
bim_snippet: PointerProperty(type=BcfBimSnippet)
958968
document_references: CollectionProperty(name="Document References", type=BcfDocumentReference)
959969
related_topics: CollectionProperty(name="Related Topics", type=StrProperty)
970+
comments: CollectionProperty(name="Comments", type=BcfComment)
960971

961972

962973
def refreshBcfTopic(self, context):
@@ -966,7 +977,7 @@ def refreshBcfTopic(self, context):
966977
props = bpy.context.scene.BCFProperties
967978
bcfxml = bcfstore.BcfStore.get_bcfxml()
968979
topic = props.topics[props.active_topic_index]
969-
header = bcfxml.get_header(topic.guid)
980+
header = bcfxml.get_header(topic.name)
970981
getBcfViewpoints(self, context)
971982

972983

@@ -1478,6 +1489,7 @@ class BIMProperties(PropertyGroup):
14781489
class BCFProperties(PropertyGroup):
14791490
is_editable: BoolProperty(name="Is Editable", default=False)
14801491
is_loaded: BoolProperty(name="Is Loaded", default=False)
1492+
comment_text_width: IntProperty(name="Comment Text Width", default=40)
14811493
name: StringProperty(default="", name="Project Name")
14821494
author: StringProperty(default="john@doe.com", name="Author Email")
14831495
topics: CollectionProperty(name="BCF Topics", type=BcfTopic)

src/ifcblenderexport/blenderbim/bim/ui.py

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ def draw(self, context):
17081708
col.prop(topic, "modified_author")
17091709

17101710
bcfxml = bcfstore.BcfStore.get_bcfxml()
1711-
bcf_topic = bcfxml.topics[topic.guid]
1711+
bcf_topic = bcfxml.topics[topic.name]
17121712

17131713
if bcf_topic.header:
17141714
layout.label(text="Header Files:")
@@ -1720,7 +1720,7 @@ def draw(self, context):
17201720
row.operator("bim.open_uri", icon="URL", text="").uri = f.reference
17211721
else:
17221722
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
1723-
op.uri = os.path.join(bcfxml.filepath, topic.guid, f.reference)
1723+
op.uri = os.path.join(bcfxml.filepath, topic.name, f.reference)
17241724
box.label(text=f.date)
17251725
#box.label(text=f.ifc_project)
17261726
#box.label(text=f.ifc_spatial_structure_element)
@@ -1751,7 +1751,7 @@ def draw(self, context):
17511751
row.operator("bim.open_uri", icon="URL", text="").uri = topic.bim_snippet.reference
17521752
else:
17531753
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
1754-
op.uri = os.path.join(bcfxml.filepath, topic.guid, topic.bim_snippet.reference)
1754+
op.uri = os.path.join(bcfxml.filepath, topic.name, topic.bim_snippet.reference)
17551755

17561756
if topic.document_references:
17571757
layout.label(text="Document References:")
@@ -1763,7 +1763,7 @@ def draw(self, context):
17631763
row.operator("bim.open_uri", icon="URL", text="").uri = doc.reference
17641764
else:
17651765
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
1766-
op.uri = os.path.join(bcfxml.filepath, topic.guid, doc.reference)
1766+
op.uri = os.path.join(bcfxml.filepath, topic.name, doc.reference)
17671767
row = box.row(align=True)
17681768
row.prop(doc, "description")
17691769

@@ -1774,6 +1774,51 @@ def draw(self, context):
17741774
row.operator("bim.view_bcf_topic", text=related_topic.name).topic_guid = related_topic.name
17751775

17761776

1777+
class BIM_PT_bcf_comments(Panel):
1778+
bl_label = "BCF Comments"
1779+
bl_idname = "BIM_PT_bcf_comments"
1780+
bl_options = {"DEFAULT_CLOSED"}
1781+
bl_space_type = "PROPERTIES"
1782+
bl_region_type = "WINDOW"
1783+
bl_context = "scene"
1784+
bl_parent_id = "BIM_PT_bcf"
1785+
1786+
def draw(self, context):
1787+
layout = self.layout
1788+
layout.use_property_split = True
1789+
1790+
scene = context.scene
1791+
props = bpy.context.scene.BCFProperties
1792+
1793+
if props.active_topic_index >= len(props.topics):
1794+
layout.label(text="No BCF project is loaded")
1795+
return
1796+
1797+
row = layout.row()
1798+
row.prop(props, "comment_text_width")
1799+
1800+
topic = props.topics[props.active_topic_index]
1801+
for comment in topic.comments:
1802+
box = self.layout.box()
1803+
box.separator()
1804+
author_text = "{} ({})".format(comment.author, comment.date)
1805+
if comment.modified_author:
1806+
author_text = "*{} ({})".format(comment.modified_author, comment.modified_date)
1807+
box.label(text=author_text, icon="WORDWRAP_ON")
1808+
box.separator()
1809+
box.scale_y = 0.5
1810+
words = comment.comment.split()
1811+
while words:
1812+
total_line_chars = 0
1813+
line_words = []
1814+
while words and total_line_chars < props.comment_text_width:
1815+
word = words.pop(0)
1816+
line_words.append(word)
1817+
total_line_chars += len(word) + 1 # 1 is for the space
1818+
box.label(text=" ".join(line_words))
1819+
box.separator()
1820+
1821+
17771822
class BIM_PT_qa(Panel):
17781823
bl_label = "BIMTester Quality Auditing"
17791824
bl_idname = "BIM_PT_qa"
@@ -2105,7 +2150,7 @@ class BIM_UL_topics(bpy.types.UIList):
21052150
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
21062151
ob = data
21072152
if item:
2108-
layout.prop(item, "name", text="", emboss=False)
2153+
layout.prop(item, "title", text="", emboss=False)
21092154
else:
21102155
layout.label(text="", translate=False)
21112156

0 commit comments

Comments
 (0)