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
@@ -0,0 +1,31 @@
import ifcopenshell
import ifcopenshell.api
class Usecase:
def __init__(self, file, **settings):
self.file = file
self.settings = {
"ifc_class": "IfcBuildingElementProxy",
"predefined_type": None,
"name": None,
}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
element = self.file.create_entity(self.settings["ifc_class"], **{
"GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file)
})
element.Name = self.settings["name"] or None
if self.settings["predefined_type"]:
if hasattr(element, "PredefinedType"):
try:
element.PredefinedType = self.settings["predefined_type"]
except:
element.PredefinedType = "USERDEFINED"
element.ObjectType = self.settings["predefined_type"]
elif hasattr(element, "ObjectType"):
element.ObjectType = self.settings["predefined_type"]
return element