diff --git a/src/ifcopenshell-python/ifcopenshell/api/classification/add_classification.py b/src/ifcopenshell-python/ifcopenshell/api/classification/add_classification.py index f66135c23d..3923a64d02 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/classification/add_classification.py +++ b/src/ifcopenshell-python/ifcopenshell/api/classification/add_classification.py @@ -2,6 +2,7 @@ import ifcopenshell import ifcopenshell.util.schema import ifcopenshell.util.date + class Usecase: def __init__(self, file, **settings): self.file = file @@ -22,16 +23,21 @@ class Usecase: # TODO: should auto date migration be part of the migrator? if self.file.schema == "IFC2X3" and edition_date: - result.EditionDate = ifcopenshell.util.date.datetime2ifc(edition_date, "IfcCalendarDate") + result.EditionDate = self.file.create_entity( + "IfcCalendarDate", **ifcopenshell.util.date.datetime2ifc(edition_date, "IfcCalendarDate") + ) else: result.EditionDate = ifcopenshell.util.date.datetime2ifc(edition_date, "IfcDate") - self.file.create_entity("IfcRelAssociatesClassification", **{ - "GlobalId": ifcopenshell.guid.new(), - "RelatedObjects": [self.file.by_type("IfcProject")[0]], - "RelatingClassification": result - }) - return # See bug #1272 + self.file.create_entity( + "IfcRelAssociatesClassification", + **{ + "GlobalId": ifcopenshell.guid.new(), + "RelatedObjects": [self.file.by_type("IfcProject")[0]], + "RelatingClassification": result, + } + ) + return result # See bug #1272 try: result = self.file.add(self.settings["classification"]) except: diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/add_application.py b/src/ifcopenshell-python/ifcopenshell/api/owner/add_application.py new file mode 100644 index 0000000000..d8f35991e2 --- /dev/null +++ b/src/ifcopenshell-python/ifcopenshell/api/owner/add_application.py @@ -0,0 +1,9 @@ +class Usecase: + def __init__(self, file, **settings): + self.file = file + self.settings = {"attributes": None} + for key, value in settings.items(): + self.settings[key] = value + + def execute(self): + return self.file.create_entity("IfcApplication", **self.settings["attributes"]) diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/settings.py b/src/ifcopenshell-python/ifcopenshell/api/owner/settings.py index f87f34a3aa..9b63baec04 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/owner/settings.py +++ b/src/ifcopenshell-python/ifcopenshell/api/owner/settings.py @@ -1,10 +1,13 @@ +# Note: it is the intent for you to override these with your own functions + + def get_person(ifc): - pass + return ifc.by_type("IfcPerson")[0] def get_organisation(ifc): - pass + return ifc.by_type("IfcOrganization")[0] def get_application(ifc): - pass + return ifc.by_type("IfcApplication")[0]