diff --git a/src/ifcblenderexport/blenderbim/__init__.py b/src/ifcblenderexport/blenderbim/__init__.py index 1ea17105b7..f8f62e8c2f 100644 --- a/src/ifcblenderexport/blenderbim/__init__.py +++ b/src/ifcblenderexport/blenderbim/__init__.py @@ -35,6 +35,7 @@ if bpy is not None: operator.SelectType, operator.SelectBcfFile, operator.GetBcfTopics, + operator.ViewBcfTopic, operator.ActivateBcfViewpoint, operator.OpenBcfReferenceLink, operator.OpenBcfBimSnippetSchema, @@ -113,6 +114,7 @@ if bpy is not None: prop.BcfTopicLabel, prop.BcfTopicLink, prop.BcfTopicDocumentReference, + prop.BcfTopicRelatedTopic, prop.Subcontext, prop.BIMProperties, prop.BCFProperties, diff --git a/src/ifcblenderexport/blenderbim/operator.py b/src/ifcblenderexport/blenderbim/operator.py index 1f5aa21a04..e4fc636db2 100644 --- a/src/ifcblenderexport/blenderbim/operator.py +++ b/src/ifcblenderexport/blenderbim/operator.py @@ -404,6 +404,18 @@ class GetBcfTopics(bpy.types.Operator): return {'FINISHED'} +class ViewBcfTopic(bpy.types.Operator): + bl_idname = 'bim.view_bcf_topic' + bl_label = 'Get BCF Topic' + topic_guid: bpy.props.StringProperty() + + def execute(self, context): + for index, topic in enumerate(bcf.BcfStore.topics): + if str(topic[1].xmlId) == self.topic_guid: + bpy.context.scene.BCFProperties.active_topic_index = index + return {'FINISHED'} + + class ActivateBcfViewpoint(bpy.types.Operator): bl_idname = 'bim.activate_bcf_viewpoint' bl_label = 'Activate BCF Viewpoint' @@ -411,7 +423,7 @@ class ActivateBcfViewpoint(bpy.types.Operator): def execute(self, context): import bcfplugin - topics = bcfplugin.getTopics() + topics = bcf.BcfStore.topics if not topics: return {'FINISHED'} topic = topics[bpy.context.scene.BCFProperties.active_topic_index][1] diff --git a/src/ifcblenderexport/blenderbim/prop.py b/src/ifcblenderexport/blenderbim/prop.py index cdd8b25d07..a05e9239d5 100644 --- a/src/ifcblenderexport/blenderbim/prop.py +++ b/src/ifcblenderexport/blenderbim/prop.py @@ -379,6 +379,11 @@ class BcfTopicDocumentReference(PropertyGroup): is_external: BoolProperty(name='Is External') +class BcfTopicRelatedTopic(PropertyGroup): + name: StringProperty(name='Name') + guid: StringProperty(name='GUID') + + def refreshBcfTopic(self, context): global bcfviewpoints_enum import bcfplugin @@ -444,6 +449,14 @@ def refreshBcfTopic(self, context): new.guid = str(doc.guid) new.is_external = doc.external + # Load related topics + while len(props.topic_related_topics) > 0: + props.topic_related_topics.remove(0) + for t in topic.relatedTopics: + new = props.topic_related_topics.add() + new.name = bcfplugin.getTopicFromUUID(t.value).title + new.guid = str(t.value) + # Load viewpoints bcfviewpoints_enum.clear() viewpoints = bcfplugin.getViewpoints(topic) @@ -558,6 +571,7 @@ class BCFProperties(PropertyGroup): topic_snippet_type: StringProperty(name='BIM Snippet Type') topic_snippet_is_external: BoolProperty(name='Is BIM Snippet External') topic_document_references: CollectionProperty(name='BCF Topic Document References', type=BcfTopicDocumentReference) + topic_related_topics: CollectionProperty(name='BCF Topic Related Topics', type=BcfTopicRelatedTopic) class MapConversion(PropertyGroup): diff --git a/src/ifcblenderexport/blenderbim/ui.py b/src/ifcblenderexport/blenderbim/ui.py index d508e6756f..5653770516 100644 --- a/src/ifcblenderexport/blenderbim/ui.py +++ b/src/ifcblenderexport/blenderbim/ui.py @@ -613,6 +613,11 @@ class BIM_PT_bcf(Panel): row.operator('bim.open_bcf_document_reference', icon='FILE_FOLDER', text='').data = '{}/{}'.format( props.topic_guid, index) + layout.label(text="Related Topics:") + for topic in props.topic_related_topics: + row = layout.row(align=True) + row.operator('bim.view_bcf_topic', text=topic.name).topic_guid = topic.guid + class BIM_PT_qa(Panel): bl_label = "BIMTester Quality Auditing"