Implement support for deleting reference links

This commit is contained in:
Dion Moult
2020-12-27 16:53:40 +11:00
parent e51b7d3c85
commit b9583c562d
3 changed files with 23 additions and 2 deletions
@@ -38,6 +38,7 @@ if bpy is not None:
operator.AddBcfHeaderFile,
operator.ViewBcfTopic,
operator.RemoveBcfComment,
operator.RemoveBcfReferenceLink,
operator.EditBcfComment,
operator.AddBcfComment,
operator.ActivateBcfViewpoint,
@@ -743,8 +743,10 @@ class AddBcfHeaderFile(bpy.types.Operator):
header_file.reference = blender_topic.file_reference
if not os.path.exists(header_file.reference):
header_file.filename = header_file.reference
header_file.ifc_project = blender_topic.file_ifc_project
header_file.ifc_spatial_structure_element = blender_topic.file_ifc_spatial_structure_element
if len(blender_topic.file_ifc_project) == 22:
header_file.ifc_project = blender_topic.file_ifc_project
if len(blender_topic.file_ifc_spatial_structure_element) == 22:
header_file.ifc_spatial_structure_element = blender_topic.file_ifc_spatial_structure_element
bcfxml.add_file(topic, header_file)
props.active_topic_index = props.active_topic_index # refreshes the BCF Topic
return {"FINISHED"}
@@ -839,6 +841,23 @@ class RemoveBcfFile(bpy.types.Operator):
return {"FINISHED"}
class RemoveBcfReferenceLink(bpy.types.Operator):
bl_idname = "bim.remove_bcf_reference_link"
bl_label = "Remove BCF Reference Link"
index: bpy.props.IntProperty()
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]
del topic.reference_links[self.index]
bcfxml.edit_topic(topic)
blender_topic.reference_links.remove(self.index)
props.active_topic_index = props.active_topic_index # Refreshes the BCF Topic
return {"FINISHED"}
class RemoveBcfComment(bpy.types.Operator):
bl_idname = "bim.remove_bcf_comment"
bl_label = "Remove BCF Comment"
@@ -1791,6 +1791,7 @@ class BIM_PT_bcf_metadata(Panel):
row = layout.row(align=True)
row.prop(link, "name")
row.operator("bim.open_uri", icon="URL", text="").uri = link.name
row.operator("bim.remove_bcf_reference_link", icon="X", text="").index = index
if topic.labels:
layout.label(text="Labels:")