mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Implement editing IFC header metadata. See #747.
This commit is contained in:
@@ -13,6 +13,9 @@ classes = (
|
||||
operator.UnassignLibraryDeclaration,
|
||||
operator.SaveLibraryFile,
|
||||
operator.AppendLibraryElement,
|
||||
operator.EnableEditingHeader,
|
||||
operator.DisableEditingHeader,
|
||||
operator.EditHeader,
|
||||
prop.LibraryElement,
|
||||
prop.BIMProjectProperties,
|
||||
ui.BIM_PT_project,
|
||||
|
||||
@@ -255,3 +255,60 @@ class AppendLibraryElement(bpy.types.Operator):
|
||||
ifc_importer.type_collection = type_collection
|
||||
ifc_importer.create_type_product(element)
|
||||
ifc_importer.place_objects_in_spatial_tree()
|
||||
|
||||
|
||||
class EnableEditingHeader(bpy.types.Operator):
|
||||
bl_idname = "bim.enable_editing_header"
|
||||
bl_label = "Enable Editing Header"
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
props = context.scene.BIMProjectProperties
|
||||
props.is_editing = True
|
||||
|
||||
mvd = "".join(IfcStore.get_file().wrapped_data.header.file_description.description)
|
||||
if "[" in mvd:
|
||||
props.mvd = mvd.split("[")[1][0:-1]
|
||||
else:
|
||||
props.mvd = ""
|
||||
|
||||
author = self.file.wrapped_data.header.file_name.author
|
||||
if author:
|
||||
props.author_name = author[0]
|
||||
if len(author) > 1:
|
||||
props.author_email = author[1]
|
||||
|
||||
organisation = self.file.wrapped_data.header.file_name.organization
|
||||
if organisation:
|
||||
props.organisation_name = organisation[0]
|
||||
if len(organisation) > 1:
|
||||
props.organisation_email = organisation[1]
|
||||
|
||||
props.authorisation = self.file.wrapped_data.header.file_name.authorization
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class EditHeader(bpy.types.Operator):
|
||||
bl_idname = "bim.edit_header"
|
||||
bl_label = "Edit Header"
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
props = context.scene.BIMProjectProperties
|
||||
props.is_editing = True
|
||||
|
||||
self.file.wrapped_data.header.file_description.description = (f'ViewDefinition[{props.mvd}]',)
|
||||
self.file.wrapped_data.header.file_name.author = (props.author_name, props.author_email)
|
||||
self.file.wrapped_data.header.file_name.organization = (props.organisation_name, props.organisation_email)
|
||||
self.file.wrapped_data.header.file_name.authorization = props.authorisation
|
||||
bpy.ops.bim.disable_editing_header()
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class DisableEditingHeader(bpy.types.Operator):
|
||||
bl_idname = "bim.disable_editing_header"
|
||||
bl_label = "Disable Editing Header"
|
||||
|
||||
def execute(self, context):
|
||||
context.scene.BIMProjectProperties.is_editing = False
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -21,6 +21,13 @@ class LibraryElement(PropertyGroup):
|
||||
|
||||
class BIMProjectProperties(PropertyGroup):
|
||||
is_authoring: BoolProperty(name="Enable Authoring Mode", default=True)
|
||||
is_editing: BoolProperty(name="Is Editing", default=False)
|
||||
mvd: StringProperty(name="MVD")
|
||||
author_name: StringProperty(name="Author")
|
||||
author_email: StringProperty(name="Author Email")
|
||||
organisation_name: StringProperty(name="Organisation")
|
||||
organisation_email: StringProperty(name="Organisation Email")
|
||||
authorisation: StringProperty(name="Authoriser")
|
||||
active_library_element: StringProperty(name="Enable Authoring Mode", default="")
|
||||
library_breadcrumb: CollectionProperty(name="Library Breadcrumb", type=StrProperty)
|
||||
library_elements: CollectionProperty(name="Library Elements", type=LibraryElement)
|
||||
|
||||
@@ -28,10 +28,40 @@ class BIM_PT_project(Panel):
|
||||
row.label(text=os.path.basename(props.ifc_file) or "No File Found")
|
||||
|
||||
if IfcStore.get_file():
|
||||
row.prop(pprops, "is_authoring", icon="GREASEPENCIL", text="")
|
||||
row.prop(pprops, "is_authoring", icon="MODIFIER", text="")
|
||||
if pprops.is_editing:
|
||||
row.operator("bim.edit_header", icon="CHECKMARK", text="")
|
||||
row.operator("bim.disable_editing_header", icon="CANCEL", text="")
|
||||
else:
|
||||
row.operator("bim.enable_editing_header", icon="GREASEPENCIL", text="")
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="IFC Schema", icon="FILE_CACHE")
|
||||
row.label(text=IfcStore.get_file().schema)
|
||||
|
||||
if pprops.is_editing:
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(pprops, "mvd")
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(pprops, "author_name")
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(pprops, "author_email")
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(pprops, "organisation_name")
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(pprops, "organisation_email")
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(pprops, "authorisation")
|
||||
else:
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="IFC MVD", icon="FILE_HIDDEN")
|
||||
mvd = "".join(IfcStore.get_file().wrapped_data.header.file_description.description)
|
||||
if "[" in mvd:
|
||||
mvd = mvd.split("[")[1][0:-1]
|
||||
row.label(text=mvd)
|
||||
else:
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="File Not Loaded", icon="ERROR")
|
||||
|
||||
Reference in New Issue
Block a user