New ifcopenshell.api.run syntax, and rename create_product to create_entity. See #1399.

This commit is contained in:
Dion Moult
2021-03-27 22:52:52 +11:00
parent 62540f0b00
commit ce03742aab
44 changed files with 490 additions and 441 deletions
@@ -1,5 +1,5 @@
import ifcopenshell
import ifcopenshell.api.owner.create_owner_history as create_owner_history
import ifcopenshell.api
class Usecase:
@@ -16,7 +16,7 @@ class Usecase:
def execute(self):
element = self.file.create_entity(self.settings["ifc_class"], **{
"GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": create_owner_history.Usecase(self.file).execute()
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file)
})
element.Name = self.settings["name"] or None
if self.settings["predefined_type"]:
@@ -1,5 +1,4 @@
import ifcopenshell.api.geometry.unassign_representation as unassign_representation
import ifcopenshell.api.geometry.remove_representation as remove_representation
import ifcopenshell.api
class Usecase:
@@ -19,9 +18,9 @@ class Usecase:
elif self.settings["product"].is_a("IfcTypeProduct"):
representations = [rm.MappedRepresentation for rm in self.settings["product"].RepresentationMaps or []]
for representation in representations:
unassign_representation.Usecase(
self.file, {"product": self.settings["product"], "representation": representation}
).execute()
remove_representation.Usecase(self.file, {"representation": representation}).execute()
ifcopenshell.api.run("owner.unassign_representation",
self.file, **{"product": self.settings["product"], "representation": representation}
)
ifcopenshell.api.run("owner.remove_representation", self.file, **{"representation": representation})
# TODO: remove object placement and other relationships
self.file.remove(self.settings["product"])