mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 06:08:32 +00:00
Implement ability to add BCF header file
This commit is contained in:
@@ -513,6 +513,19 @@ class BcfXml:
|
|||||||
os.remove(filepath)
|
os.remove(filepath)
|
||||||
self.edit_topic(topic)
|
self.edit_topic(topic)
|
||||||
|
|
||||||
|
def add_file(self, topic, header_file):
|
||||||
|
if os.path.exists(header_file.reference):
|
||||||
|
topic_filepath = os.path.join(self.filepath, topic.guid)
|
||||||
|
header_file.filename = os.path.basename(header_file.reference)
|
||||||
|
copyfile(header_file.reference, os.path.join(topic_filepath, header_file.filename))
|
||||||
|
header_file.reference = header_file.filename
|
||||||
|
header_file.is_external = False
|
||||||
|
header_file.date = datetime.utcnow().isoformat()
|
||||||
|
if not topic.header:
|
||||||
|
topic.header = bcf.data.Header()
|
||||||
|
topic.header.files.append(header_file)
|
||||||
|
self.edit_topic(topic)
|
||||||
|
|
||||||
def get_comments(self, guid):
|
def get_comments(self, guid):
|
||||||
comments = {}
|
comments = {}
|
||||||
data = self._read_xml(os.path.join(guid, "markup.bcf"), "markup.xsd")
|
data = self._read_xml(os.path.join(guid, "markup.bcf"), "markup.xsd")
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ if bpy is not None:
|
|||||||
operator.EditBcfTopic,
|
operator.EditBcfTopic,
|
||||||
operator.SaveBcfProject,
|
operator.SaveBcfProject,
|
||||||
operator.AddBcfTopic,
|
operator.AddBcfTopic,
|
||||||
|
operator.AddBcfHeaderFile,
|
||||||
operator.ViewBcfTopic,
|
operator.ViewBcfTopic,
|
||||||
operator.RemoveBcfComment,
|
operator.RemoveBcfComment,
|
||||||
operator.EditBcfComment,
|
operator.EditBcfComment,
|
||||||
@@ -45,6 +46,7 @@ if bpy is not None:
|
|||||||
operator.RemoveBcfFile,
|
operator.RemoveBcfFile,
|
||||||
operator.OpenUri,
|
operator.OpenUri,
|
||||||
operator.OpenBcfReferenceLink,
|
operator.OpenBcfReferenceLink,
|
||||||
|
operator.SelectBcfHeaderFile,
|
||||||
operator.SelectFeaturesDir,
|
operator.SelectFeaturesDir,
|
||||||
operator.SelectDiffJsonFile,
|
operator.SelectDiffJsonFile,
|
||||||
operator.SelectDiffNewFile,
|
operator.SelectDiffNewFile,
|
||||||
|
|||||||
@@ -730,6 +730,26 @@ class AddBcfTopic(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class AddBcfHeaderFile(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.add_bcf_header_file"
|
||||||
|
bl_label = "Add BCF Header File"
|
||||||
|
|
||||||
|
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]
|
||||||
|
header_file = bcf.data.HeaderFile()
|
||||||
|
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
|
||||||
|
bcfxml.add_file(topic, header_file)
|
||||||
|
props.active_topic_index = props.active_topic_index # refreshes the BCF Topic
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class ViewBcfTopic(bpy.types.Operator):
|
class ViewBcfTopic(bpy.types.Operator):
|
||||||
bl_idname = "bim.view_bcf_topic"
|
bl_idname = "bim.view_bcf_topic"
|
||||||
bl_label = "Get BCF Topic"
|
bl_label = "Get BCF Topic"
|
||||||
@@ -2308,6 +2328,24 @@ class SelectSmartGroup(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class SelectBcfHeaderFile(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.select_bcf_header_file"
|
||||||
|
bl_label = "Select BCF Header File"
|
||||||
|
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||||
|
target: bpy.props.StringProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
if self.filepath:
|
||||||
|
props = bpy.context.scene.BCFProperties
|
||||||
|
topic = props.topics[props.active_topic_index]
|
||||||
|
topic.file_reference = self.filepath
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
context.window_manager.fileselect_add(self)
|
||||||
|
return {"RUNNING_MODAL"}
|
||||||
|
|
||||||
|
|
||||||
class SelectFeaturesDir(bpy.types.Operator):
|
class SelectFeaturesDir(bpy.types.Operator):
|
||||||
bl_idname = "bim.select_features_dir"
|
bl_idname = "bim.select_features_dir"
|
||||||
bl_label = "Select Features Directory"
|
bl_label = "Select Features Directory"
|
||||||
|
|||||||
@@ -1013,6 +1013,9 @@ class BcfTopic(PropertyGroup):
|
|||||||
description: StringProperty(default="", name="Description")
|
description: StringProperty(default="", name="Description")
|
||||||
viewpoints: EnumProperty(items=getBcfViewpoints, name="BCF Viewpoints")
|
viewpoints: EnumProperty(items=getBcfViewpoints, name="BCF Viewpoints")
|
||||||
files: CollectionProperty(name="Files", type=StrProperty)
|
files: CollectionProperty(name="Files", type=StrProperty)
|
||||||
|
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=StrProperty)
|
||||||
labels: CollectionProperty(name="Labels", type=StrProperty)
|
labels: CollectionProperty(name="Labels", type=StrProperty)
|
||||||
bim_snippet: PointerProperty(type=BcfBimSnippet)
|
bim_snippet: PointerProperty(type=BcfBimSnippet)
|
||||||
|
|||||||
@@ -1759,9 +1759,31 @@ class BIM_PT_bcf_metadata(Panel):
|
|||||||
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
|
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
|
||||||
op.uri = os.path.join(bcfxml.filepath, topic.name, f.reference)
|
op.uri = os.path.join(bcfxml.filepath, topic.name, f.reference)
|
||||||
row.operator("bim.remove_bcf_file", icon="X", text="").index = index
|
row.operator("bim.remove_bcf_file", icon="X", text="").index = index
|
||||||
box.label(text=f.date)
|
|
||||||
# box.label(text=f.ifc_project)
|
row = box.row()
|
||||||
# box.label(text=f.ifc_spatial_structure_element)
|
row.label(text="Date")
|
||||||
|
row.label(text=f.date)
|
||||||
|
|
||||||
|
if f.ifc_project:
|
||||||
|
row = box.row()
|
||||||
|
row.label(text="IFC Project")
|
||||||
|
row.label(text=f.ifc_project)
|
||||||
|
|
||||||
|
if f.ifc_spatial_structure_element:
|
||||||
|
row = box.row()
|
||||||
|
row.label(text="IFC Spatial Structure Element")
|
||||||
|
row.label(text=f.ifc_spatial_structure_element)
|
||||||
|
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.prop(topic, "file_reference")
|
||||||
|
row.operator("bim.select_bcf_header_file", icon="FILE_FOLDER", text="")
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(topic, "file_ifc_project")
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(topic, "file_ifc_spatial_structure_element")
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
row.operator("bim.add_bcf_header_file")
|
||||||
|
|
||||||
if topic.reference_links:
|
if topic.reference_links:
|
||||||
layout.label(text="Reference Links:")
|
layout.label(text="Reference Links:")
|
||||||
|
|||||||
Reference in New Issue
Block a user