mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Implement support for deleting BCF header files
This commit is contained in:
+10
-1
@@ -272,7 +272,7 @@ class BcfXml:
|
||||
f.write(self.document.toprettyxml(encoding="utf-8"))
|
||||
|
||||
def write_header(self, header, root):
|
||||
if not header:
|
||||
if not header or not header.files:
|
||||
return
|
||||
header_el = self._create_element(root, "Header")
|
||||
for f in header.files:
|
||||
@@ -504,6 +504,15 @@ class BcfXml:
|
||||
del topic.viewpoints[guid]
|
||||
self.edit_topic(topic)
|
||||
|
||||
def delete_file(self, topic, index):
|
||||
if not topic.header:
|
||||
return
|
||||
f = topic.header.files.pop(index)
|
||||
filepath = os.path.join(self.filepath, topic.guid, f.reference)
|
||||
if not f.is_external and os.path.exists(filepath):
|
||||
os.remove(filepath)
|
||||
self.edit_topic(topic)
|
||||
|
||||
def get_comments(self, guid):
|
||||
comments = {}
|
||||
data = self._read_xml(os.path.join(guid, "markup.bcf"), "markup.xsd")
|
||||
|
||||
@@ -42,6 +42,7 @@ if bpy is not None:
|
||||
operator.ActivateBcfViewpoint,
|
||||
operator.AddBcfViewpoint,
|
||||
operator.RemoveBcfViewpoint,
|
||||
operator.RemoveBcfFile,
|
||||
operator.OpenUri,
|
||||
operator.OpenBcfReferenceLink,
|
||||
operator.SelectFeaturesDir,
|
||||
|
||||
@@ -803,6 +803,21 @@ class RemoveBcfViewpoint(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class RemoveBcfFile(bpy.types.Operator):
|
||||
bl_idname = "bim.remove_bcf_file"
|
||||
bl_label = "Remove BCF File"
|
||||
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]
|
||||
bcfxml.delete_file(topic, 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"
|
||||
|
||||
@@ -1747,7 +1747,7 @@ class BIM_PT_bcf_metadata(Panel):
|
||||
bcfxml = bcfstore.BcfStore.get_bcfxml()
|
||||
bcf_topic = bcfxml.topics[topic.name]
|
||||
|
||||
if bcf_topic.header:
|
||||
if bcf_topic.header and bcf_topic.header.files:
|
||||
layout.label(text="Header Files:")
|
||||
for index, f in enumerate(bcf_topic.header.files):
|
||||
box = self.layout.box()
|
||||
@@ -1758,6 +1758,7 @@ class BIM_PT_bcf_metadata(Panel):
|
||||
else:
|
||||
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
|
||||
op.uri = os.path.join(bcfxml.filepath, topic.name, f.reference)
|
||||
row.operator("bim.remove_bcf_file", icon="X", text="").index = index
|
||||
box.label(text=f.date)
|
||||
# box.label(text=f.ifc_project)
|
||||
# box.label(text=f.ifc_spatial_structure_element)
|
||||
|
||||
Reference in New Issue
Block a user