diff --git a/src/bcf/bcf/bcfxml.py b/src/bcf/bcf/bcfxml.py index 2b03be6812..c1291283f7 100644 --- a/src/bcf/bcf/bcfxml.py +++ b/src/bcf/bcf/bcfxml.py @@ -304,14 +304,15 @@ class BcfXml: if comment.viewpoint: self._create_element(comment_el, "Viewpoint", {"Guid": comment.viewpoint.guid}) - def add_comment(self, comment=None): + def add_comment(self, topic, comment=None): if comment is None: comment = bcf.data.Comment() if not comment.guid: comment.guid = str(uuid.uuid4()) if not comment.comment: comment.comment = "'Free software' is a matter of liberty, not price. To understand the concept, you should think of 'free' as in 'free speech,' not as in 'free beer'." - self.edit_comment(comment) + topic.comments[comment.guid] = comment + self.edit_comment(comment, topic) def edit_comment(self, comment, topic): if not comment.date: diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index 017f5a17e9..5a956f6159 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -38,6 +38,7 @@ if bpy is not None: operator.ViewBcfTopic, operator.RemoveBcfViewpoint, operator.RemoveBcfComment, + operator.AddBcfComment, operator.ActivateBcfViewpoint, operator.OpenUri, operator.OpenBcfReferenceLink, diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index 69ce23f783..1f11523145 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -1,5 +1,6 @@ import os import bpy +import bcf import uuid import time import json @@ -766,7 +767,28 @@ class RemoveBcfComment(bpy.types.Operator): blender_topic = props.topics[props.active_topic_index] topic = bcfxml.topics[blender_topic.name] bcfxml.delete_comment(self.comment_guid, topic) - props.active_topic_index = props.active_topic_index # Refreshes the BCF Topic + bpy.ops.bim.load_bcf_comments(topic_guid = topic.guid) + return {"FINISHED"} + + +class AddBcfComment(bpy.types.Operator): + bl_idname = "bim.add_bcf_comment" + bl_label = "Add BCF Comment" + comment_guid: bpy.props.StringProperty() + + def execute(self, context): + bcfxml = bcfstore.BcfStore.get_bcfxml() + props = bpy.context.scene.BCFProperties + blender_topic = props.topics[props.active_topic_index] + topic = bcfxml.topics[blender_topic.name] + if not blender_topic.comment: + return {"FINISHED"} + comment = bcf.data.Comment() + comment.comment = blender_topic.comment + if blender_topic.has_related_viewpoint and blender_topic.viewpoints: + comment.viewpoint = bcf.data.Viewpoint() + comment.viewpoint.guid = blender_topic.viewpoints + bcfxml.add_comment(topic, comment) bpy.ops.bim.load_bcf_comments(topic_guid = topic.guid) print(bcfxml.filepath) return {"FINISHED"} diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index 6b59f51f99..4b83aa25bd 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -1006,6 +1006,8 @@ class BcfTopic(PropertyGroup): related_topics: CollectionProperty(name="Related Topics", type=StrProperty) comments: CollectionProperty(name="Comments", type=BcfComment) is_editable: BoolProperty(name="Is Editable", default=False, update=updateBcfTopicIsEditable) + comment: StringProperty(default="", name="Comment") + has_related_viewpoint: BoolProperty(name="Has Related Viewpoint", default=False) class PropertySetTemplate(PropertyGroup): diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index 48afe4913d..43fdf91170 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -1857,6 +1857,13 @@ class BIM_PT_bcf_comments(Panel): total_line_chars += len(word) + 1 # 1 is for the space col.label(text=" ".join(line_words)) + row = layout.row() + row.prop(topic, "comment") + row = layout.row() + row.prop(topic, "has_related_viewpoint") + row = layout.row() + row.operator("bim.add_bcf_comment") + class BIM_PT_qa(Panel): bl_label = "BIMTester Quality Auditing"