diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index 13abc613bd..2912567d05 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -40,6 +40,7 @@ if bpy is not None: operator.ViewBcfTopic, operator.RemoveBcfComment, operator.RemoveBcfReferenceLink, + operator.EditBcfReferenceLinks, operator.EditBcfComment, operator.AddBcfComment, operator.ActivateBcfViewpoint, @@ -251,6 +252,7 @@ if bpy is not None: operator.SnapSpacesTogether, operator.CopyGrid, prop.StrProperty, + prop.BcfReferenceLink, prop.Attribute, prop.MaterialLayer, prop.MaterialConstituent, diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index 4cfd6be8ff..ae66656b95 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -860,6 +860,23 @@ class AddBcfReferenceLink(bpy.types.Operator): return {"FINISHED"} +class EditBcfReferenceLinks(bpy.types.Operator): + bl_idname = "bim.edit_bcf_reference_links" + bl_label = "Edit BCF Reference Link" + + 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] + for index, reference_link in enumerate(topic.reference_links): + if reference_link == blender_topic.reference_links[index].name: + continue + topic.reference_links[index] = blender_topic.reference_links[index].name + bcfxml.edit_topic(topic) + return {"FINISHED"} + + class RemoveBcfReferenceLink(bpy.types.Operator): bl_idname = "bim.remove_bcf_reference_link" bl_label = "Remove BCF Reference Link" diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index 591adf4183..eaecd710d9 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -167,6 +167,10 @@ def refreshPredefinedTypes(self, context): context.scene.BIMProperties.ifc_predefined_type = enum[0][0] +def updateBcfReferenceLink(self, context): + bpy.ops.bim.edit_bcf_reference_links() + + def getDiagramScales(self, context): global diagram_scales_enum if ( @@ -587,6 +591,10 @@ def refreshBcfTopic(self, context): getBcfViewpoints(self, context) +class BcfReferenceLink(PropertyGroup): + name: StringProperty(name="Name", update=updateBcfReferenceLink) + + class StrProperty(PropertyGroup): pass @@ -1016,7 +1024,7 @@ class BcfTopic(PropertyGroup): file_reference: StringProperty(default="", name="Reference") file_ifc_project: StringProperty(default="", name="IFC Project") file_ifc_spatial_structure_element: StringProperty(default="", name="IFC Spatial Structure Element") - reference_links: CollectionProperty(name="Reference Links", type=StrProperty) + reference_links: CollectionProperty(name="Reference Links", type=BcfReferenceLink) reference_link: StringProperty(default="", name="Reference Link") labels: CollectionProperty(name="Labels", type=StrProperty) bim_snippet: PointerProperty(type=BcfBimSnippet)