Replace .wrapped_data.header with .header (dfaa8d5)

This commit is contained in:
Andrej730
2025-09-15 16:47:09 +05:00
parent a3c6e295c8
commit cc7732ecbf
9 changed files with 35 additions and 35 deletions
+4 -4
View File
@@ -74,12 +74,12 @@ class IfcExporter:
json.dump(jsonData, outfile, indent=None if self.ifc_export_settings.json_compact else 4) json.dump(jsonData, outfile, indent=None if self.ifc_export_settings.json_compact else 4)
def set_header(self): def set_header(self):
self.file.wrapped_data.header.file_name.name = os.path.basename(self.ifc_export_settings.output_file) self.file.header.file_name.name = os.path.basename(self.ifc_export_settings.output_file)
self.file.wrapped_data.header.file_name.time_stamp = ( self.file.header.file_name.time_stamp = (
datetime.datetime.utcnow().replace(tzinfo=datetime.UTC).astimezone().replace(microsecond=0).isoformat() datetime.datetime.utcnow().replace(tzinfo=datetime.UTC).astimezone().replace(microsecond=0).isoformat()
) )
self.file.wrapped_data.header.file_name.preprocessor_version = "IfcOpenShell {}".format(ifcopenshell.version) self.file.header.file_name.preprocessor_version = "IfcOpenShell {}".format(ifcopenshell.version)
self.file.wrapped_data.header.file_name.originating_system = "{} {}".format( self.file.header.file_name.originating_system = "{} {}".format(
self.get_application_name(), tool.Blender.get_bonsai_version() self.get_application_name(), tool.Blender.get_bonsai_version()
) )
+1 -1
View File
@@ -132,7 +132,7 @@ class IfcStore:
def generate_cache_path() -> str: def generate_cache_path() -> str:
"""Generate cache path based on the active file and it's path.""" """Generate cache path based on the active file and it's path."""
assert IfcStore.file assert IfcStore.file
ifc_key = IfcStore.path + IfcStore.file.wrapped_data.header.file_name.time_stamp ifc_key = IfcStore.path + IfcStore.file.header.file_name.time_stamp
ifc_hash = hashlib.md5(ifc_key.encode("utf-8")).hexdigest() ifc_hash = hashlib.md5(ifc_key.encode("utf-8")).hexdigest()
prefs = tool.Blender.get_addon_preferences() prefs = tool.Blender.get_addon_preferences()
cache_path = os.path.join(prefs.cache_dir, f"{ifc_hash}.h5") cache_path = os.path.join(prefs.cache_dir, f"{ifc_hash}.h5")
@@ -60,8 +60,8 @@ class CopyDebugInformation(bpy.types.Operator):
{ {
"ifc": os.path.basename(tool.Ifc.get_path()) if os.path.isfile(tool.Ifc.get_path()) else "Unsaved", "ifc": os.path.basename(tool.Ifc.get_path()) if os.path.isfile(tool.Ifc.get_path()) else "Unsaved",
"schema": tool.Ifc.get().schema, "schema": tool.Ifc.get().schema,
"preprocessor_version": tool.Ifc.get().wrapped_data.header.file_name.preprocessor_version, "preprocessor_version": tool.Ifc.get().header.file_name.preprocessor_version,
"originating_system": tool.Ifc.get().wrapped_data.header.file_name.originating_system, "originating_system": tool.Ifc.get().header.file_name.originating_system,
} }
) )
+1 -1
View File
@@ -96,7 +96,7 @@ class ProjectData:
if not ifc: if not ifc:
return "" return ""
try: try:
save_datetime = ifc.wrapped_data.header.file_name.time_stamp save_datetime = ifc.header.file_name.time_stamp
save_date, save_time = save_datetime.split("T") save_date, save_time = save_datetime.split("T")
return f"{save_date} {':'.join(save_time.split(':')[0:2])}" return f"{save_date} {':'.join(save_time.split(':')[0:2])}"
except: except:
@@ -850,25 +850,25 @@ class EnableEditingHeader(bpy.types.Operator):
props = tool.Project.get_project_props() props = tool.Project.get_project_props()
props.is_editing = True props.is_editing = True
mvd = "".join(tool.Ifc.get().wrapped_data.header.file_description.description) mvd = "".join(tool.Ifc.get().header.file_description.description)
if "[" in mvd: if "[" in mvd:
props.mvd = mvd.split("[")[1][0:-1] props.mvd = mvd.split("[")[1][0:-1]
else: else:
props.mvd = "" props.mvd = ""
author = self.file.wrapped_data.header.file_name.author author = self.file.header.file_name.author
if author: if author:
props.author_name = author[0] props.author_name = author[0]
if len(author) > 1: if len(author) > 1:
props.author_email = author[1] props.author_email = author[1]
organisation = self.file.wrapped_data.header.file_name.organization organisation = self.file.header.file_name.organization
if organisation: if organisation:
props.organisation_name = organisation[0] props.organisation_name = organisation[0]
if len(organisation) > 1: if len(organisation) > 1:
props.organisation_email = organisation[1] props.organisation_email = organisation[1]
props.authorisation = self.file.wrapped_data.header.file_name.authorization or "" props.authorisation = self.file.header.file_name.authorization or ""
return {"FINISHED"} return {"FINISHED"}
@@ -897,35 +897,35 @@ class EditHeader(bpy.types.Operator):
props = tool.Project.get_project_props() props = tool.Project.get_project_props()
props.is_editing = True props.is_editing = True
self.file.wrapped_data.header.file_description.description = (f"ViewDefinition[{props.mvd}]",) self.file.header.file_description.description = (f"ViewDefinition[{props.mvd}]",)
self.file.wrapped_data.header.file_name.author = (props.author_name, props.author_email) self.file.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.header.file_name.organization = (props.organisation_name, props.organisation_email)
self.file.wrapped_data.header.file_name.authorization = props.authorisation self.file.header.file_name.authorization = props.authorisation
bpy.ops.bim.disable_editing_header() bpy.ops.bim.disable_editing_header()
return {"FINISHED"} return {"FINISHED"}
def record_state(self): def record_state(self):
self.file = tool.Ifc.get() self.file = tool.Ifc.get()
return { return {
"description": self.file.wrapped_data.header.file_description.description, "description": self.file.header.file_description.description,
"author": self.file.wrapped_data.header.file_name.author, "author": self.file.header.file_name.author,
"organisation": self.file.wrapped_data.header.file_name.organization, "organisation": self.file.header.file_name.organization,
"authorisation": self.file.wrapped_data.header.file_name.authorization, "authorisation": self.file.header.file_name.authorization,
} }
def rollback(self, data): def rollback(self, data):
file = tool.Ifc.get() file = tool.Ifc.get()
file.wrapped_data.header.file_description.description = data["old"]["description"] file.header.file_description.description = data["old"]["description"]
file.wrapped_data.header.file_name.author = data["old"]["author"] file.header.file_name.author = data["old"]["author"]
file.wrapped_data.header.file_name.organization = data["old"]["organisation"] file.header.file_name.organization = data["old"]["organisation"]
file.wrapped_data.header.file_name.authorization = data["old"]["authorisation"] file.header.file_name.authorization = data["old"]["authorisation"]
def commit(self, data): def commit(self, data):
file = tool.Ifc.get() file = tool.Ifc.get()
file.wrapped_data.header.file_description.description = data["new"]["description"] file.header.file_description.description = data["new"]["description"]
file.wrapped_data.header.file_name.author = data["new"]["author"] file.header.file_name.author = data["new"]["author"]
file.wrapped_data.header.file_name.organization = data["new"]["organisation"] file.header.file_name.organization = data["new"]["organisation"]
file.wrapped_data.header.file_name.authorization = data["new"]["authorisation"] file.header.file_name.authorization = data["new"]["authorisation"]
class DisableEditingHeader(bpy.types.Operator): class DisableEditingHeader(bpy.types.Operator):
+1 -1
View File
@@ -288,7 +288,7 @@ class BIM_PT_project(Panel):
if isinstance(ifc_file, ifcopenshell.sqlite): if isinstance(ifc_file, ifcopenshell.sqlite):
mvd = ifc_file.mvd_str mvd = ifc_file.mvd_str
else: else:
mvd = "".join(ifc_file.wrapped_data.header.file_description.description) mvd = "".join(ifc_file.header.file_description.description)
if "[" in mvd: if "[" in mvd:
mvd = mvd.split("[")[1][0:-1] mvd = mvd.split("[")[1][0:-1]
row.label(text=mvd) row.label(text=mvd)
+1 -1
View File
@@ -309,7 +309,7 @@ class CA2IFC:
return ifcopenshell.guid.new() return ifcopenshell.guid.new()
def create_header(self): def create_header(self):
self.f.wrapped_data.header.file_name.name = os.path.basename(self.outputFilename) self.f.header.file_name.name = os.path.basename(self.outputFilename)
def create_global_axes(self): def create_global_axes(self):
self.xAxis = self.f.createIfcDirection((1.0, 0.0, 0.0)) self.xAxis = self.f.createIfcDirection((1.0, 0.0, 0.0))
@@ -59,7 +59,7 @@ def step_impl(context, version):
) )
def step_impl(context, header_file_description): def step_impl(context, header_file_description):
is_header_file_description = IfcStore.file.wrapped_data.header.file_description.description is_header_file_description = IfcStore.file.header.file_description.description
assert ( assert (
str(is_header_file_description) == header_file_description str(is_header_file_description) == header_file_description
), "The file was not exported by the new ifc exporter in Allplan. File description header: {}".format( ), "The file was not exported by the new ifc exporter in Allplan. File description header: {}".format(
+4 -4
View File
@@ -55,16 +55,16 @@ class Patcher:
self.logger = logger self.logger = logger
def patch(self): def patch(self):
self.file.wrapped_data.header.file_name.name = "Rabbit" self.file.header.file_name.name = "Rabbit"
self.file.wrapped_data.header.file_name.time_stamp = ( self.file.header.file_name.time_stamp = (
datetime.datetime.utcnow() datetime.datetime.utcnow()
.replace(tzinfo=datetime.timezone.utc) .replace(tzinfo=datetime.timezone.utc)
.astimezone() .astimezone()
.replace(microsecond=0) .replace(microsecond=0)
.isoformat() .isoformat()
) )
self.file.wrapped_data.header.file_name.preprocessor_version = "Rabbit" self.file.header.file_name.preprocessor_version = "Rabbit"
self.file.wrapped_data.header.file_name.originating_system = "Rabbit" self.file.header.file_name.originating_system = "Rabbit"
for element in self.file.by_type("IfcApplication"): for element in self.file.by_type("IfcApplication"):
element.Version = "Rabbit" element.Version = "Rabbit"