mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 02:31:09 +00:00
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:
@@ -202,6 +202,7 @@ def ensureIfcExported(scene):
|
|||||||
|
|
||||||
|
|
||||||
def get_application(ifc):
|
def get_application(ifc):
|
||||||
|
# TODO: cache this for even faster application retrieval. It honestly makes a difference on long scripts.
|
||||||
version = get_application_version()
|
version = get_application_version()
|
||||||
for element in ifc.by_type("IfcApplication"):
|
for element in ifc.by_type("IfcApplication"):
|
||||||
if element.ApplicationIdentifier == "BlenderBIM" and element.Version == version:
|
if element.ApplicationIdentifier == "BlenderBIM" and element.Version == version:
|
||||||
@@ -209,7 +210,7 @@ def get_application(ifc):
|
|||||||
return ifcopenshell.api.run(
|
return ifcopenshell.api.run(
|
||||||
"owner.add_application",
|
"owner.add_application",
|
||||||
ifc,
|
ifc,
|
||||||
version=get_application_version(),
|
version=version,
|
||||||
application_full_name="BlenderBIM Add-on",
|
application_full_name="BlenderBIM Add-on",
|
||||||
application_identifier="BlenderBIM",
|
application_identifier="BlenderBIM",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1211,12 +1211,12 @@ class IfcImporter:
|
|||||||
elif element.is_a("IfcGridAxis"):
|
elif element.is_a("IfcGridAxis"):
|
||||||
return
|
return
|
||||||
elif element.GlobalId in self.collections:
|
elif element.GlobalId in self.collections:
|
||||||
return self.collections[element.GlobalId].objects.link(obj)
|
collection = self.collections[element.GlobalId]
|
||||||
elif getattr(element, "Decomposes", None):
|
|
||||||
aggregate = ifcopenshell.util.element.get_aggregate(element)
|
|
||||||
collection = self.collections[aggregate.GlobalId]
|
|
||||||
collection.name = obj.name
|
collection.name = obj.name
|
||||||
return collection.objects.link(obj)
|
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:
|
else:
|
||||||
return self.place_object_in_spatial_decomposition_collection(element, obj)
|
return self.place_object_in_spatial_decomposition_collection(element, obj)
|
||||||
|
|
||||||
|
|||||||
@@ -61,10 +61,11 @@ class CreateProject(bpy.types.Operator):
|
|||||||
)
|
)
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
|
|
||||||
person = blenderbim.core.owner.add_person(tool.Ifc)
|
if self.file.schema == "IFC2X3":
|
||||||
organisation = blenderbim.core.owner.add_organisation(tool.Ifc)
|
person = blenderbim.core.owner.add_person(tool.Ifc)
|
||||||
user = blenderbim.core.owner.add_person_and_organisation(tool.Ifc, person=person, organisation=organisation)
|
organisation = blenderbim.core.owner.add_organisation(tool.Ifc)
|
||||||
blenderbim.core.owner.set_user(tool.Owner, user=user)
|
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)
|
project = bpy.data.objects.new(self.get_name("IfcProject", "My Project"), None)
|
||||||
site = bpy.data.objects.new(self.get_name("IfcSite", "My Site"), None)
|
site = bpy.data.objects.new(self.get_name("IfcSite", "My Site"), None)
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ class Usecase:
|
|||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
user = ifcopenshell.api.owner.settings.get_user(self.file)
|
user = ifcopenshell.api.owner.settings.get_user(self.file)
|
||||||
|
if self.file.schema != "IFC2X3" and not user:
|
||||||
|
return
|
||||||
application = ifcopenshell.api.owner.settings.get_application(self.file)
|
application = ifcopenshell.api.owner.settings.get_application(self.file)
|
||||||
if self.file.schema != "IFC2X3":
|
if self.file.schema != "IFC2X3" and not application:
|
||||||
if not user or not application:
|
return
|
||||||
return
|
|
||||||
return self.file.create_entity(
|
return self.file.create_entity(
|
||||||
"IfcOwnerHistory",
|
"IfcOwnerHistory",
|
||||||
**{
|
**{
|
||||||
|
|||||||
@@ -15,8 +15,10 @@ class Usecase:
|
|||||||
if not hasattr(self.settings["element"], "OwnerHistory"):
|
if not hasattr(self.settings["element"], "OwnerHistory"):
|
||||||
return
|
return
|
||||||
user = ifcopenshell.api.owner.settings.get_user(self.file)
|
user = ifcopenshell.api.owner.settings.get_user(self.file)
|
||||||
|
if not user:
|
||||||
|
return
|
||||||
application = ifcopenshell.api.owner.settings.get_application(self.file)
|
application = ifcopenshell.api.owner.settings.get_application(self.file)
|
||||||
if not user or not application:
|
if not application:
|
||||||
return
|
return
|
||||||
if not self.settings["element"].OwnerHistory:
|
if not self.settings["element"].OwnerHistory:
|
||||||
self.settings["element"].OwnerHistory = ifcopenshell.api.run(
|
self.settings["element"].OwnerHistory = ifcopenshell.api.run(
|
||||||
|
|||||||
Reference in New Issue
Block a user