Optimise owner check depending on your implementation and no longer create default users on IFC4. Can result in 50% faster script running on long scripted operations.

This commit is contained in:
Dion Moult
2021-10-29 18:04:17 +11:00
parent 4bf4622498
commit 109149a0be
5 changed files with 18 additions and 13 deletions
+2 -1
View File
@@ -202,6 +202,7 @@ def ensureIfcExported(scene):
def get_application(ifc):
# TODO: cache this for even faster application retrieval. It honestly makes a difference on long scripts.
version = get_application_version()
for element in ifc.by_type("IfcApplication"):
if element.ApplicationIdentifier == "BlenderBIM" and element.Version == version:
@@ -209,7 +210,7 @@ def get_application(ifc):
return ifcopenshell.api.run(
"owner.add_application",
ifc,
version=get_application_version(),
version=version,
application_full_name="BlenderBIM Add-on",
application_identifier="BlenderBIM",
)
+4 -4
View File
@@ -1211,12 +1211,12 @@ class IfcImporter:
elif element.is_a("IfcGridAxis"):
return
elif element.GlobalId in self.collections:
return self.collections[element.GlobalId].objects.link(obj)
elif getattr(element, "Decomposes", None):
aggregate = ifcopenshell.util.element.get_aggregate(element)
collection = self.collections[aggregate.GlobalId]
collection = self.collections[element.GlobalId]
collection.name = obj.name
return collection.objects.link(obj)
elif getattr(element, "Decomposes", None):
aggregate = ifcopenshell.util.element.get_aggregate(element)
return self.collections[aggregate.GlobalId].objects.link(obj)
else:
return self.place_object_in_spatial_decomposition_collection(element, obj)
@@ -61,10 +61,11 @@ class CreateProject(bpy.types.Operator):
)
self.file = IfcStore.get_file()
person = blenderbim.core.owner.add_person(tool.Ifc)
organisation = blenderbim.core.owner.add_organisation(tool.Ifc)
user = blenderbim.core.owner.add_person_and_organisation(tool.Ifc, person=person, organisation=organisation)
blenderbim.core.owner.set_user(tool.Owner, user=user)
if self.file.schema == "IFC2X3":
person = blenderbim.core.owner.add_person(tool.Ifc)
organisation = blenderbim.core.owner.add_organisation(tool.Ifc)
user = blenderbim.core.owner.add_person_and_organisation(tool.Ifc, person=person, organisation=organisation)
blenderbim.core.owner.set_user(tool.Owner, user=user)
project = bpy.data.objects.new(self.get_name("IfcProject", "My Project"), None)
site = bpy.data.objects.new(self.get_name("IfcSite", "My Site"), None)