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
+2 -2
View File
@@ -7,7 +7,7 @@ import zipfile
import tempfile import tempfile
import ifcopenshell import ifcopenshell
import ifcopenshell.util.placement import ifcopenshell.util.placement
import ifcopenshell.api.root.remove_product as remove_product import ifcopenshell.api
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
import addon_utils import addon_utils
@@ -90,7 +90,7 @@ class IfcExporter:
for guid in to_delete: for guid in to_delete:
product = self.file.by_id(guid) product = self.file.by_id(guid)
IfcStore.unlink_element(product) IfcStore.unlink_element(product)
remove_product.Usecase(self.file, {"product": product}).execute() ifcopenshell.api.run("remove_product", self.file, **{"product": product})
def sync_edited_objects(self): def sync_edited_objects(self):
for obj_name in IfcStore.edited_objs.copy(): for obj_name in IfcStore.edited_objs.copy():
@@ -1,5 +1,5 @@
import bpy import bpy
import ifcopenshell.api.aggregate.assign_object as assign_object import ifcopenshell.api
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.aggregate.data import Data from ifcopenshell.api.aggregate.data import Data
@@ -18,13 +18,14 @@ class AssignObject(bpy.types.Operator):
if not relating_object or not relating_object.BIMObjectProperties.ifc_definition_id: if not relating_object or not relating_object.BIMObjectProperties.ifc_definition_id:
return {"FINISHED"} return {"FINISHED"}
product = self.file.by_id(props.ifc_definition_id) product = self.file.by_id(props.ifc_definition_id)
assign_object.Usecase( ifcopenshell.api.run(
"aggregate.assign_object",
self.file, self.file,
{ **{
"product": product, "product": product,
"relating_object": self.file.by_id(relating_object.BIMObjectProperties.ifc_definition_id), "relating_object": self.file.by_id(relating_object.BIMObjectProperties.ifc_definition_id),
}, },
).execute() )
bpy.ops.bim.edit_object_placement(obj=related_object.name) bpy.ops.bim.edit_object_placement(obj=related_object.name)
Data.load(IfcStore.get_file(), props.ifc_definition_id) Data.load(IfcStore.get_file(), props.ifc_definition_id)
bpy.ops.bim.disable_editing_aggregate(obj=related_object.name) bpy.ops.bim.disable_editing_aggregate(obj=related_object.name)
@@ -1,7 +1,7 @@
import bpy import bpy
import json import json
import ifcopenshell import ifcopenshell
import ifcopenshell.api.attribute.edit_attributes as edit_attributes import ifcopenshell.api
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.attribute.data import Data from ifcopenshell.api.attribute.data import Data
@@ -33,7 +33,7 @@ class EnableEditingAttributes(bpy.types.Operator):
elif attribute["type"] == "integer": elif attribute["type"] == "integer":
new.int_value = attribute["value"] or 0 new.int_value = attribute["value"] or 0
elif attribute["type"] == "float": elif attribute["type"] == "float":
new.float_value = attribute["value"] or 0. new.float_value = attribute["value"] or 0.0
elif attribute["type"] == "enum": elif attribute["type"] == "enum":
new.enum_items = json.dumps(attribute["enum_items"]) new.enum_items = json.dumps(attribute["enum_items"])
if attribute["value"]: if attribute["value"]:
@@ -95,10 +95,9 @@ class EditAttributes(bpy.types.Operator):
elif attribute["type"] == "enum": elif attribute["type"] == "enum":
attributes[attribute["name"]] = blender_attribute.enum_value attributes[attribute["name"]] = blender_attribute.enum_value
product = self.file.by_id(oprops.ifc_definition_id) product = self.file.by_id(oprops.ifc_definition_id)
edit_attributes.Usecase(self.file, { ifcopenshell.api.run(
"product": product, "attribute.edit_attributes", self.file, **{"product": product, "attributes": attributes}
"attributes": attributes )
}).execute()
if "Name" in attributes: if "Name" in attributes:
new_name = "{}/{}".format(product.is_a(), product.Name or "Unnamed") new_name = "{}/{}".format(product.is_a(), product.Name or "Unnamed")
collection = bpy.data.collections.get(obj.name) collection = bpy.data.collections.get(obj.name)
@@ -1,11 +1,6 @@
import bpy import bpy
import json import json
import ifcopenshell.api.classification.add_classification as add_classification import ifcopenshell.api
import ifcopenshell.api.classification.remove_classification as remove_classification
import ifcopenshell.api.classification.edit_classification as edit_classification
import ifcopenshell.api.classification.add_reference as add_reference
import ifcopenshell.api.classification.remove_reference as remove_reference
import ifcopenshell.api.classification.edit_reference as edit_reference
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.classification.data import Data from ifcopenshell.api.classification.data import Data
from blenderbim.bim.module.classification.prop import getClassifications, getReferences from blenderbim.bim.module.classification.prop import getClassifications, getReferences
@@ -34,9 +29,11 @@ class AddClassification(bpy.types.Operator):
def execute(self, context): def execute(self, context):
props = context.scene.BIMClassificationProperties props = context.scene.BIMClassificationProperties
add_classification.Usecase( ifcopenshell.api.run(
IfcStore.get_file(), {"classification": Data.library_file.by_id(int(props.available_classifications))} "classification.add_classification",
).execute() IfcStore.get_file(),
**{"classification": Data.library_file.by_id(int(props.available_classifications))},
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -80,7 +77,11 @@ class RemoveClassification(bpy.types.Operator):
def execute(self, context): def execute(self, context):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_classification.Usecase(self.file, {"classification": self.file.by_id(self.classification)}).execute() ifcopenshell.api.run(
"classification.remove_classification",
self.file,
**{"classification": self.file.by_id(self.classification)},
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -100,9 +101,11 @@ class EditClassification(bpy.types.Operator):
else: else:
attributes[attribute.name] = attribute.string_value attributes[attribute.name] = attribute.string_value
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
edit_classification.Usecase( ifcopenshell.api.run(
self.file, {"classification": self.file.by_id(props.active_classification_id), "attributes": attributes} "classification.edit_classification",
).execute() self.file,
**{"classification": self.file.by_id(props.active_classification_id), "attributes": attributes},
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.disable_editing_classification() bpy.ops.bim.disable_editing_classification()
return {"FINISHED"} return {"FINISHED"}
@@ -152,13 +155,14 @@ class RemoveClassificationReference(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_reference.Usecase( ifcopenshell.api.run(
"classification.remove_reference",
self.file, self.file,
{ **{
"reference": self.file.by_id(self.reference), "reference": self.file.by_id(self.reference),
"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id), "product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id),
}, },
).execute() )
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id) Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -179,9 +183,11 @@ class EditClassificationReference(bpy.types.Operator):
else: else:
attributes[attribute.name] = attribute.string_value attributes[attribute.name] = attribute.string_value
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
edit_reference.Usecase( ifcopenshell.api.run(
self.file, {"reference": self.file.by_id(props.active_reference_id), "attributes": attributes} "classification.edit_reference",
).execute() self.file,
**{"reference": self.file.by_id(props.active_reference_id), "attributes": attributes},
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.disable_editing_classification_reference() bpy.ops.bim.disable_editing_classification_reference()
return {"FINISHED"} return {"FINISHED"}
@@ -206,14 +212,15 @@ class AddClassificationReference(bpy.types.Operator):
classification = self.file.by_id(classification_id) classification = self.file.by_id(classification_id)
break break
add_reference.Usecase( ifcopenshell.api.run(
"classification.add_reference",
self.file, self.file,
{ **{
"reference": Data.library_file.by_id(self.reference), "reference": Data.library_file.by_id(self.reference),
"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id), "product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id),
"classification": classification "classification": classification,
}, },
).execute() )
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id) Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -1,11 +1,7 @@
import bpy import bpy
import json import json
import ifcopenshell.api
import ifcopenshell.util.attribute import ifcopenshell.util.attribute
import ifcopenshell.api.constraint.add_objective as add_objective
import ifcopenshell.api.constraint.edit_objective as edit_objective
import ifcopenshell.api.constraint.remove_constraint as remove_constraint
import ifcopenshell.api.constraint.assign_constraint as assign_constraint
import ifcopenshell.api.constraint.unassign_constraint as unassign_constraint
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.constraint.data import Data from ifcopenshell.api.constraint.data import Data
@@ -83,7 +79,7 @@ class AddObjective(bpy.types.Operator):
bl_label = "Add Objective" bl_label = "Add Objective"
def execute(self, context): def execute(self, context):
result = add_objective.Usecase(IfcStore.get_file()).execute() result = ifcopenshell.api.run("constraint.add_objective", IfcStore.get_file())
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_objectives() bpy.ops.bim.load_objectives()
bpy.ops.bim.enable_editing_constraint(constraint=result.id()) bpy.ops.bim.enable_editing_constraint(constraint=result.id())
@@ -105,9 +101,11 @@ class EditObjective(bpy.types.Operator):
else: else:
attributes[attribute.name] = attribute.string_value attributes[attribute.name] = attribute.string_value
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
edit_objective.Usecase( ifcopenshell.api.run(
self.file, {"objective": self.file.by_id(props.active_constraint_id), "attributes": attributes} "constraint.edit_objective",
).execute() self.file,
**{"objective": self.file.by_id(props.active_constraint_id), "attributes": attributes}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_objectives() bpy.ops.bim.load_objectives()
return {"FINISHED"} return {"FINISHED"}
@@ -121,7 +119,9 @@ class RemoveConstraint(bpy.types.Operator):
def execute(self, context): def execute(self, context):
props = context.scene.BIMConstraintProperties props = context.scene.BIMConstraintProperties
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_constraint.Usecase(self.file, {"constraint": self.file.by_id(self.constraint)}).execute() ifcopenshell.api.run(
"constraint.remove_constraint", self.file, **{"constraint": self.file.by_id(self.constraint)}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
if props.is_editing == "IfcObjective": if props.is_editing == "IfcObjective":
bpy.ops.bim.load_objectives() bpy.ops.bim.load_objectives()
@@ -163,10 +163,14 @@ class AssignConstraint(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
assign_constraint.Usecase(self.file, { ifcopenshell.api.run(
"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id), "constraint.assign_constraint",
"constraint": self.file.by_id(self.constraint) self.file,
}).execute() **{
"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id),
"constraint": self.file.by_id(self.constraint),
}
)
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id) Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
return {"FINISHED"} return {"FINISHED"}
@@ -180,9 +184,13 @@ class UnassignConstraint(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
unassign_constraint.Usecase(self.file, { ifcopenshell.api.run(
"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id), "constraint.unassign_constraint",
"constraint": self.file.by_id(self.constraint) self.file,
}).execute() **{
"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id),
"constraint": self.file.by_id(self.constraint),
}
)
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id) Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
return {"FINISHED"} return {"FINISHED"}
@@ -1,6 +1,5 @@
import bpy import bpy
import ifcopenshell.api.context.add_context as add_context import ifcopenshell.api
import ifcopenshell.api.context.remove_context as remove_context
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.context.data import Data from ifcopenshell.api.context.data import Data
@@ -14,14 +13,15 @@ class AddSubcontext(bpy.types.Operator):
def execute(self, context): def execute(self, context):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
add_context.Usecase( ifcopenshell.api.run(
"context.add_context",
self.file, self.file,
{ **{
"context": self.context or bpy.context.scene.BIMProperties.available_contexts, "context": self.context or bpy.context.scene.BIMProperties.available_contexts,
"subcontext": self.subcontext or bpy.context.scene.BIMProperties.available_subcontexts, "subcontext": self.subcontext or bpy.context.scene.BIMProperties.available_subcontexts,
"target_view": self.target_view or bpy.context.scene.BIMProperties.available_target_views, "target_view": self.target_view or bpy.context.scene.BIMProperties.available_target_views,
}, },
).execute() )
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -33,7 +33,8 @@ class RemoveSubcontext(bpy.types.Operator):
def execute(self, context): def execute(self, context):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
usecase = remove_context.Usecase(self.file, {"context": self.file.by_id(self.ifc_definition_id)}) ifcopenshell.api.run(
usecase.execute() "context.remove_context", self.file, **{"context": self.file.by_id(self.ifc_definition_id)}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -1,13 +1,7 @@
import bpy import bpy
import json import json
import ifcopenshell.api
import ifcopenshell.util.attribute import ifcopenshell.util.attribute
import ifcopenshell.api.document.add_information as add_information
import ifcopenshell.api.document.add_reference as add_reference
import ifcopenshell.api.document.edit_information as edit_information
import ifcopenshell.api.document.edit_reference as edit_reference
import ifcopenshell.api.document.remove_document as remove_document
import ifcopenshell.api.document.assign_document as assign_document
import ifcopenshell.api.document.unassign_document as unassign_document
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.document.data import Data from ifcopenshell.api.document.data import Data
@@ -116,7 +110,7 @@ class AddInformation(bpy.types.Operator):
bl_label = "Add Information" bl_label = "Add Information"
def execute(self, context): def execute(self, context):
result = add_information.Usecase(IfcStore.get_file()).execute() result = ifcopenshell.api.run("document.add_information", IfcStore.get_file())
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_information() bpy.ops.bim.load_information()
bpy.ops.bim.enable_editing_document(document=result.id()) bpy.ops.bim.enable_editing_document(document=result.id())
@@ -128,7 +122,7 @@ class AddDocumentReference(bpy.types.Operator):
bl_label = "Add Document Reference" bl_label = "Add Document Reference"
def execute(self, context): def execute(self, context):
result = add_reference.Usecase(IfcStore.get_file()).execute() result = ifcopenshell.api.run("document.add_reference", IfcStore.get_file())
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_document_references() bpy.ops.bim.load_document_references()
bpy.ops.bim.enable_editing_document(document=result.id()) bpy.ops.bim.enable_editing_document(document=result.id())
@@ -150,9 +144,11 @@ class EditInformation(bpy.types.Operator):
else: else:
attributes[attribute.name] = attribute.string_value attributes[attribute.name] = attribute.string_value
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
edit_information.Usecase( ifcopenshell.api.run(
self.file, {"information": self.file.by_id(props.active_document_id), "attributes": attributes} "document.edit_information",
).execute() self.file,
**{"information": self.file.by_id(props.active_document_id), "attributes": attributes}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_information() bpy.ops.bim.load_information()
return {"FINISHED"} return {"FINISHED"}
@@ -171,9 +167,11 @@ class EditDocumentReference(bpy.types.Operator):
else: else:
attributes[attribute.name] = attribute.string_value attributes[attribute.name] = attribute.string_value
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
edit_reference.Usecase( ifcopenshell.api.run(
self.file, {"reference": self.file.by_id(props.active_document_id), "attributes": attributes} "document.edit_reference",
).execute() self.file,
**{"reference": self.file.by_id(props.active_document_id), "attributes": attributes}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_document_references() bpy.ops.bim.load_document_references()
return {"FINISHED"} return {"FINISHED"}
@@ -187,7 +185,7 @@ class RemoveDocument(bpy.types.Operator):
def execute(self, context): def execute(self, context):
props = context.scene.BIMDocumentProperties props = context.scene.BIMDocumentProperties
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_document.Usecase(self.file, {"document": self.file.by_id(self.document)}).execute() ifcopenshell.api.run("document.remove_document", self.file, **{"document": self.file.by_id(self.document)})
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
if props.is_editing == "information": if props.is_editing == "information":
bpy.ops.bim.load_information() bpy.ops.bim.load_information()
@@ -233,10 +231,14 @@ class AssignDocument(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
assign_document.Usecase(self.file, { ifcopenshell.api.run(
"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id), "document.assign_document",
"document": self.file.by_id(self.document) self.file,
}).execute() **{
"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id),
"document": self.file.by_id(self.document),
}
)
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id) Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
return {"FINISHED"} return {"FINISHED"}
@@ -250,9 +252,13 @@ class UnassignDocument(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
unassign_document.Usecase(self.file, { ifcopenshell.api.run(
"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id), "document.unassign_document",
"document": self.file.by_id(self.document) self.file,
}).execute() **{
"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id),
"document": self.file.by_id(self.document),
}
)
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id) Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
return {"FINISHED"} return {"FINISHED"}
@@ -4,14 +4,7 @@ import ifcopenshell
import ifcopenshell.util.unit import ifcopenshell.util.unit
import ifcopenshell.util.element import ifcopenshell.util.element
import logging import logging
import ifcopenshell.api.geometry.edit_object_placement as edit_object_placement import ifcopenshell.api
import ifcopenshell.api.geometry.add_representation as add_representation
import ifcopenshell.api.geometry.map_representation as map_representation
import ifcopenshell.api.geometry.assign_styles as assign_styles
import ifcopenshell.api.geometry.assign_representation as assign_representation
import ifcopenshell.api.geometry.unassign_representation as unassign_representation
import ifcopenshell.api.geometry.remove_representation as remove_representation
import ifcopenshell.api.grid.create_axis_curve as create_axis_curve
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from blenderbim.bim import import_ifc from blenderbim.bim import import_ifc
from ifcopenshell.api.geometry.data import Data from ifcopenshell.api.geometry.data import Data
@@ -55,13 +48,14 @@ class EditObjectPlacement(bpy.types.Operator):
float(props.blender_x_axis_ordinate), float(props.blender_x_axis_ordinate),
) )
) )
edit_object_placement.Usecase( ifcopenshell.api.run(
"geometry.edit_object_placement",
self.file, self.file,
{ **{
"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id), "product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id),
"matrix": matrix, "matrix": matrix,
}, },
).execute() )
return {"FINISHED"} return {"FINISHED"}
@@ -103,7 +97,7 @@ class AddRepresentation(bpy.types.Operator):
"should_force_triangulation": context.scene.BIMGeometryProperties.should_force_triangulation, "should_force_triangulation": context.scene.BIMGeometryProperties.should_force_triangulation,
} }
result = add_representation.Usecase(self.file, representation_data).execute() result = ifcopenshell.api.run("geometry.add_representation", self.file, **representation_data)
if not result: if not result:
print("Failed to write shape representation") print("Failed to write shape representation")
@@ -117,12 +111,15 @@ class AddRepresentation(bpy.types.Operator):
and context_of_items.ContextIdentifier == "Body" and context_of_items.ContextIdentifier == "Body"
): ):
representation_data["context"] = self.file.by_id(box_context_id) representation_data["context"] = self.file.by_id(box_context_id)
new_box = add_representation.Usecase(self.file, representation_data).execute() new_box = ifcopenshell.api.run("geometry.add_representation", self.file, **representation_data)
assign_representation.Usecase(self.file, {"product": product, "representation": new_box}).execute() ifcopenshell.api.run(
"geometry.assign_representation", self.file, **{"product": product, "representation": new_box}
)
assign_styles.Usecase( ifcopenshell.api.run(
"geometry.assign_styles",
self.file, self.file,
{ **{
"shape_representation": result, "shape_representation": result,
"styles": [ "styles": [
self.file.by_id(s.material.BIMMaterialProperties.ifc_style_id) self.file.by_id(s.material.BIMMaterialProperties.ifc_style_id)
@@ -131,8 +128,10 @@ class AddRepresentation(bpy.types.Operator):
], ],
"should_use_presentation_style_assignment": context.scene.BIMGeometryProperties.should_use_presentation_style_assignment, "should_use_presentation_style_assignment": context.scene.BIMGeometryProperties.should_use_presentation_style_assignment,
}, },
).execute() )
assign_representation.Usecase(self.file, {"product": product, "representation": result}).execute() ifcopenshell.api.run(
"geometry.assign_representation", self.file, **{"product": product, "representation": result}
)
existing_mesh = obj.data existing_mesh = obj.data
mesh = obj.data.copy() mesh = obj.data.copy()
@@ -231,8 +230,10 @@ class RemoveRepresentation(bpy.types.Operator):
if not is_mapped_representation: if not is_mapped_representation:
bpy.data.meshes.remove(mesh) bpy.data.meshes.remove(mesh)
product = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id) product = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
unassign_representation.Usecase(self.file, {"product": product, "representation": representation}).execute() ifcopenshell.api.run(
remove_representation.Usecase(self.file, {"representation": representation}).execute() "geometry.unassign_representation", self.file, **{"product": product, "representation": representation}
)
ifcopenshell.api.run("geometry.remove_representation", self.file, **{"representation": representation})
Data.load(IfcStore.get_file(), product.id()) Data.load(IfcStore.get_file(), product.id())
return {"FINISHED"} return {"FINISHED"}
@@ -282,10 +283,12 @@ class MapRepresentation(bpy.types.Operator):
product = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id) product = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
if obj_data: if obj_data:
obj.data = obj_data obj.data = obj_data
result = map_representation.Usecase( result = ifcopenshell.api.run(
self.file, {"representation": self.file.by_id(self.representation_id)} "geometry.map_representation", self.file, **{"representation": self.file.by_id(self.representation_id)}
).execute() )
assign_representation.Usecase(self.file, {"product": product, "representation": result}).execute() ifcopenshell.api.run(
"geometry.assign_representation", self.file, **{"product": product, "representation": result}
)
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id) Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
return {"FINISHED"} return {"FINISHED"}
@@ -312,7 +315,7 @@ class UpdateMeshRepresentation(bpy.types.Operator):
product = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id) product = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
if product.is_a("IfcGridAxis"): if product.is_a("IfcGridAxis"):
create_axis_curve.Usecase(self.file, {"AxisCurve": obj, "grid_axis": product}).execute() ifcopenshell.api.run("grid.create_axis_curve", self.file, **{"AxisCurve": obj, "grid_axis": product})
return return
bpy.ops.bim.edit_object_placement(obj=obj.name) bpy.ops.bim.edit_object_placement(obj=obj.name)
@@ -339,12 +342,12 @@ class UpdateMeshRepresentation(bpy.types.Operator):
"total_items": max(1, len(obj.material_slots)), "total_items": max(1, len(obj.material_slots)),
"should_force_faceted_brep": context.scene.BIMGeometryProperties.should_force_faceted_brep, "should_force_faceted_brep": context.scene.BIMGeometryProperties.should_force_faceted_brep,
"should_force_triangulation": context.scene.BIMGeometryProperties.should_force_triangulation, "should_force_triangulation": context.scene.BIMGeometryProperties.should_force_triangulation,
"ifc_representation_class": self.ifc_representation_class "ifc_representation_class": self.ifc_representation_class,
} }
new_representation = add_representation.Usecase(self.file, representation_data).execute() new_representation = ifcopenshell.api.run("geometry.add_representation", self.file, **representation_data)
#if product.is_a("IfcWall"): # if product.is_a("IfcWall"):
# # Generate axis representation # # Generate axis representation
# axis_context_id = get_context_id("Model", "Axis", "MODEL_VIEW") # axis_context_id = get_context_id("Model", "Axis", "MODEL_VIEW")
# old_axis = ifcopenshell.util.element.get_representation(product, "Model", "Axis", "MODEL_VIEW") # old_axis = ifcopenshell.util.element.get_representation(product, "Model", "Axis", "MODEL_VIEW")
@@ -371,13 +374,14 @@ class UpdateMeshRepresentation(bpy.types.Operator):
and context_of_items.ContextIdentifier == "Body" and context_of_items.ContextIdentifier == "Body"
): ):
representation_data["context"] = self.file.by_id(box_context_id) representation_data["context"] = self.file.by_id(box_context_id)
new_box = add_representation.Usecase(self.file, representation_data).execute() new_box = ifcopenshell.api.run("geometry.add_representation", self.file, **representation_data)
for inverse in self.file.get_inverse(old_box): for inverse in self.file.get_inverse(old_box):
ifcopenshell.util.element.replace_attribute(inverse, old_box, new_box) ifcopenshell.util.element.replace_attribute(inverse, old_box, new_box)
assign_styles.Usecase( ifcopenshell.api.run(
"geometry.assign_styles",
self.file, self.file,
{ **{
"shape_representation": new_representation, "shape_representation": new_representation,
"styles": [ "styles": [
self.file.by_id(s.material.BIMMaterialProperties.ifc_style_id) self.file.by_id(s.material.BIMMaterialProperties.ifc_style_id)
@@ -386,7 +390,7 @@ class UpdateMeshRepresentation(bpy.types.Operator):
], ],
"should_use_presentation_style_assignment": context.scene.BIMGeometryProperties.should_use_presentation_style_assignment, "should_use_presentation_style_assignment": context.scene.BIMGeometryProperties.should_use_presentation_style_assignment,
}, },
).execute() )
# TODO: move this into a replace_representation usecase or something # TODO: move this into a replace_representation usecase or something
for inverse in self.file.get_inverse(old_representation): for inverse in self.file.get_inverse(old_representation):
@@ -3,9 +3,7 @@ import json
import ifcopenshell import ifcopenshell
import ifcopenshell.util.unit import ifcopenshell.util.unit
import ifcopenshell.util.attribute import ifcopenshell.util.attribute
import ifcopenshell.api.georeference.add_georeferencing as add_georeferencing import ifcopenshell.api
import ifcopenshell.api.georeference.edit_georeferencing as edit_georeferencing
import ifcopenshell.api.georeference.remove_georeferencing as remove_georeferencing
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.georeference.data import Data from ifcopenshell.api.georeference.data import Data
from math import radians, degrees, atan, tan, cos, sin from math import radians, degrees, atan, tan, cos, sin
@@ -131,9 +129,11 @@ class EditGeoreferencing(bpy.types.Operator):
if not props.is_map_unit_null: if not props.is_map_unit_null:
map_unit = props.map_unit_si if props.map_unit_type == "IfcSIUnit" else props.map_unit_imperial map_unit = props.map_unit_si if props.map_unit_type == "IfcSIUnit" else props.map_unit_imperial
edit_georeferencing.Usecase( ifcopenshell.api.run(
self.file, {"map_conversion": map_conversion, "projected_crs": projected_crs, "map_unit": map_unit} "georeference.edit_georeferencing",
).execute() self.file,
**{"map_conversion": map_conversion, "projected_crs": projected_crs, "map_unit": map_unit}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.disable_editing_georeferencing() bpy.ops.bim.disable_editing_georeferencing()
return {"FINISHED"} return {"FINISHED"}
@@ -169,7 +169,7 @@ class RemoveGeoreferencing(bpy.types.Operator):
bl_label = "Remove Georeferencing" bl_label = "Remove Georeferencing"
def execute(self, context): def execute(self, context):
remove_georeferencing.Usecase(IfcStore.get_file()).execute() ifcopenshell.api.run("georeference.remove_georeferencing", IfcStore.get_file())
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -179,7 +179,7 @@ class AddGeoreferencing(bpy.types.Operator):
bl_label = "Add Georeferencing" bl_label = "Add Georeferencing"
def execute(self, context): def execute(self, context):
add_georeferencing.Usecase(IfcStore.get_file()).execute() ifcopenshell.api.run("georeference.add_georeferencing", IfcStore.get_file())
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -1,10 +1,6 @@
import bpy import bpy
import ifcopenshell.util.attribute import ifcopenshell.util.attribute
import ifcopenshell.api.group.add_group as add_group import ifcopenshell.api
import ifcopenshell.api.group.edit_group as edit_group
import ifcopenshell.api.group.remove_group as remove_group
import ifcopenshell.api.group.assign_group as assign_group
import ifcopenshell.api.group.unassign_group as unassign_group
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.group.data import Data from ifcopenshell.api.group.data import Data
@@ -40,7 +36,7 @@ class AddGroup(bpy.types.Operator):
bl_label = "Add Group" bl_label = "Add Group"
def execute(self, context): def execute(self, context):
result = add_group.Usecase(IfcStore.get_file()).execute() result = ifcopenshell.api.run("group.add_group", IfcStore.get_file())
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_groups() bpy.ops.bim.load_groups()
bpy.ops.bim.enable_editing_group(group=result.id()) bpy.ops.bim.enable_editing_group(group=result.id())
@@ -60,9 +56,9 @@ class EditGroup(bpy.types.Operator):
else: else:
attributes[attribute.name] = attribute.string_value attributes[attribute.name] = attribute.string_value
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
edit_group.Usecase( ifcopenshell.api.run(
self.file, {"group": self.file.by_id(props.active_group_id), "attributes": attributes} "group.edit_group", self.file, **{"group": self.file.by_id(props.active_group_id), "attributes": attributes}
).execute() )
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_groups() bpy.ops.bim.load_groups()
return {"FINISHED"} return {"FINISHED"}
@@ -76,7 +72,7 @@ class RemoveGroup(bpy.types.Operator):
def execute(self, context): def execute(self, context):
props = context.scene.BIMGroupProperties props = context.scene.BIMGroupProperties
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_group.Usecase(self.file, {"group": self.file.by_id(self.group)}).execute() ifcopenshell.api.run("group.remove_group", self.file, **{"group": self.file.by_id(self.group)})
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_groups() bpy.ops.bim.load_groups()
return {"FINISHED"} return {"FINISHED"}
@@ -125,10 +121,14 @@ class AssignGroup(bpy.types.Operator):
def execute(self, context): def execute(self, context):
product = bpy.data.objects.get(self.product) if self.product else context.active_object product = bpy.data.objects.get(self.product) if self.product else context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
assign_group.Usecase(self.file, { ifcopenshell.api.run(
"product": self.file.by_id(product.BIMObjectProperties.ifc_definition_id), "group.assign_group",
"group": self.file.by_id(self.group) self.file,
}).execute() **{
"product": self.file.by_id(product.BIMObjectProperties.ifc_definition_id),
"group": self.file.by_id(self.group),
}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -142,9 +142,13 @@ class UnassignGroup(bpy.types.Operator):
def execute(self, context): def execute(self, context):
product = bpy.data.objects.get(self.product) if self.product else context.active_object product = bpy.data.objects.get(self.product) if self.product else context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
unassign_group.Usecase(self.file, { ifcopenshell.api.run(
"product": self.file.by_id(product.BIMObjectProperties.ifc_definition_id), "group.unassign_group",
"group": self.file.by_id(self.group) self.file,
}).execute() **{
"product": self.file.by_id(product.BIMObjectProperties.ifc_definition_id),
"group": self.file.by_id(self.group),
}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -1,11 +1,7 @@
import bpy import bpy
import json import json
import ifcopenshell.util.attribute import ifcopenshell.util.attribute
import ifcopenshell.api.layer.add_layer as add_layer import ifcopenshell.api
import ifcopenshell.api.layer.edit_layer as edit_layer
import ifcopenshell.api.layer.remove_layer as remove_layer
import ifcopenshell.api.layer.assign_layer as assign_layer
import ifcopenshell.api.layer.unassign_layer as unassign_layer
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.layer.data import Data from ifcopenshell.api.layer.data import Data
@@ -76,7 +72,7 @@ class AddPresentationLayer(bpy.types.Operator):
bl_label = "Add Layer" bl_label = "Add Layer"
def execute(self, context): def execute(self, context):
result = add_layer.Usecase(IfcStore.get_file()).execute() result = ifcopenshell.api.run("layer.add_layer", IfcStore.get_file())
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_layers() bpy.ops.bim.load_layers()
bpy.ops.bim.enable_editing_layer(layer=result.id()) bpy.ops.bim.enable_editing_layer(layer=result.id())
@@ -96,9 +92,9 @@ class EditPresentationLayer(bpy.types.Operator):
else: else:
attributes[attribute.name] = attribute.string_value attributes[attribute.name] = attribute.string_value
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
edit_layer.Usecase( ifcopenshell.api.run(
self.file, {"layer": self.file.by_id(props.active_layer_id), "attributes": attributes} "layer.edit_layer", self.file, **{"layer": self.file.by_id(props.active_layer_id), "attributes": attributes}
).execute() )
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_layers() bpy.ops.bim.load_layers()
return {"FINISHED"} return {"FINISHED"}
@@ -112,7 +108,7 @@ class RemovePresentationLayer(bpy.types.Operator):
def execute(self, context): def execute(self, context):
props = context.scene.BIMLayerProperties props = context.scene.BIMLayerProperties
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_layer.Usecase(self.file, {"layer": self.file.by_id(self.layer)}).execute() ifcopenshell.api.run("layer.remove_layer", self.file, **{"layer": self.file.by_id(self.layer)})
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_layers() bpy.ops.bim.load_layers()
return {"FINISHED"} return {"FINISHED"}
@@ -127,10 +123,11 @@ class AssignPresentationLayer(bpy.types.Operator):
def execute(self, context): def execute(self, context):
item = bpy.data.meshes.get(self.item) if self.item else context.active_object.data item = bpy.data.meshes.get(self.item) if self.item else context.active_object.data
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
assign_layer.Usecase(self.file, { ifcopenshell.api.run(
"item": self.file.by_id(item.BIMMeshProperties.ifc_definition_id), "layer.assign_layer",
"layer": self.file.by_id(self.layer) self.file,
}).execute() **{"item": self.file.by_id(item.BIMMeshProperties.ifc_definition_id), "layer": self.file.by_id(self.layer)}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -144,9 +141,10 @@ class UnassignPresentationLayer(bpy.types.Operator):
def execute(self, context): def execute(self, context):
item = bpy.data.meshes.get(self.item) if self.item else context.active_object.data item = bpy.data.meshes.get(self.item) if self.item else context.active_object.data
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
unassign_layer.Usecase(self.file, { ifcopenshell.api.run(
"item": self.file.by_id(item.BIMMeshProperties.ifc_definition_id), "layer.unassign_layer",
"layer": self.file.by_id(self.layer) self.file,
}).execute() **{"item": self.file.by_id(item.BIMMeshProperties.ifc_definition_id), "layer": self.file.by_id(self.layer)}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -1,18 +1,6 @@
import bpy import bpy
import ifcopenshell.api
import ifcopenshell.util.attribute import ifcopenshell.util.attribute
import ifcopenshell.api.material.add_material as add_material
import ifcopenshell.api.material.remove_material as remove_material
import ifcopenshell.api.material.assign_material as assign_material
import ifcopenshell.api.material.unassign_material as unassign_material
import ifcopenshell.api.material.add_constituent as add_constituent
import ifcopenshell.api.material.remove_constituent as remove_constituent
import ifcopenshell.api.material.add_layer as add_layer
import ifcopenshell.api.material.edit_layer as edit_layer
import ifcopenshell.api.material.remove_layer as remove_layer
import ifcopenshell.api.material.reorder_set_item as reorder_set_item
import ifcopenshell.api.material.add_list_item as add_list_item
import ifcopenshell.api.material.remove_list_item as remove_list_item
import ifcopenshell.api.material.edit_assigned_material as edit_assigned_material
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.material.data import Data from ifcopenshell.api.material.data import Data
@@ -25,7 +13,7 @@ class AddMaterial(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = bpy.data.materials.get(self.obj) if self.obj else bpy.context.active_object.active_material obj = bpy.data.materials.get(self.obj) if self.obj else bpy.context.active_object.active_material
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
result = add_material.Usecase(self.file, {"Name": obj.name}).execute() result = ifcopenshell.api.run("material.add_material", self.file, **{"Name": obj.name})
obj.BIMObjectProperties.ifc_definition_id = result.id() obj.BIMObjectProperties.ifc_definition_id = result.id()
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -39,9 +27,11 @@ class RemoveMaterial(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = bpy.data.materials.get(self.obj) if self.obj else bpy.context.active_object.active_material obj = bpy.data.materials.get(self.obj) if self.obj else bpy.context.active_object.active_material
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
result = remove_material.Usecase( result = ifcopenshell.api.run(
self.file, {"material": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)} "material.remove_material",
).execute() self.file,
**{"material": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)},
)
obj.BIMObjectProperties.ifc_definition_id = 0 obj.BIMObjectProperties.ifc_definition_id = 0
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -57,14 +47,15 @@ class AssignMaterial(bpy.types.Operator):
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
material_type = self.material_type or obj.BIMObjectMaterialProperties.material_type material_type = self.material_type or obj.BIMObjectMaterialProperties.material_type
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
assign_material.Usecase( ifcopenshell.api.run(
"material.assign_material",
self.file, self.file,
{ **{
"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id), "product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id),
"type": material_type, "type": material_type,
"material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material)), "material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material)),
}, },
).execute() )
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id) Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
return {"FINISHED"} return {"FINISHED"}
@@ -78,9 +69,11 @@ class UnassignMaterial(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
unassign_material.Usecase( ifcopenshell.api.run(
self.file, {"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)} "material.unassign_material",
).execute() self.file,
**{"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)},
)
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id) Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
return {"FINISHED"} return {"FINISHED"}
@@ -94,13 +87,14 @@ class AddConstituent(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
add_constituent.Usecase( ifcopenshell.api.run(
"material.add_constituent",
self.file, self.file,
{ **{
"constituent_set": self.file.by_id(self.constituent_set), "constituent_set": self.file.by_id(self.constituent_set),
"material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material)), "material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material)),
}, },
).execute() )
Data.load_constituents() Data.load_constituents()
return {"FINISHED"} return {"FINISHED"}
@@ -114,7 +108,9 @@ class RemoveConstituent(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_constituent.Usecase(self.file, {"constituent": self.file.by_id(self.constituent)}).execute() ifcopenshell.api.run(
"material.remove_constituent", self.file, **{"constituent": self.file.by_id(self.constituent)}
)
Data.load_constituents() Data.load_constituents()
return {"FINISHED"} return {"FINISHED"}
@@ -128,13 +124,14 @@ class AddLayer(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
add_layer.Usecase( ifcopenshell.api.run(
"material.add_layer",
self.file, self.file,
{ **{
"layer_set": self.file.by_id(self.layer_set), "layer_set": self.file.by_id(self.layer_set),
"material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material)), "material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material)),
}, },
).execute() )
Data.load_layers() Data.load_layers()
return {"FINISHED"} return {"FINISHED"}
@@ -151,14 +148,15 @@ class ReorderMaterialSetItem(bpy.types.Operator):
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
material_set = self.file.by_id(self.material_set) material_set = self.file.by_id(self.material_set)
reorder_set_item.Usecase( ifcopenshell.api.run(
"material.reorder_set_item",
self.file, self.file,
{ **{
"material_set": material_set, "material_set": material_set,
"old_index": self.old_index, "old_index": self.old_index,
"new_index": self.new_index, "new_index": self.new_index,
}, },
).execute() )
if material_set.is_a("IfcMaterialConstituentSet"): if material_set.is_a("IfcMaterialConstituentSet"):
Data.load_constituents() Data.load_constituents()
elif material_set.is_a("IfcMaterialLayerSet"): elif material_set.is_a("IfcMaterialLayerSet"):
@@ -179,7 +177,7 @@ class RemoveLayer(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_layer.Usecase(self.file, {"layer": self.file.by_id(self.layer)}).execute() ifcopenshell.api.run("material.remove_layer", self.file, **{"layer": self.file.by_id(self.layer)})
Data.load_layers() Data.load_layers()
return {"FINISHED"} return {"FINISHED"}
@@ -193,13 +191,14 @@ class AddListItem(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
add_list_item.Usecase( ifcopenshell.api.run(
"material.add_list_item",
self.file, self.file,
{ **{
"material_list": self.file.by_id(self.list_item_set), "material_list": self.file.by_id(self.list_item_set),
"material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material)), "material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material)),
}, },
).execute() )
Data.load_lists() Data.load_lists()
return {"FINISHED"} return {"FINISHED"}
@@ -214,13 +213,14 @@ class RemoveListItem(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_list_item.Usecase( ifcopenshell.api.run(
"material.remove_list_item",
self.file, self.file,
{ **{
"material_list": self.file.by_id(self.list_item_set), "material_list": self.file.by_id(self.list_item_set),
"material": self.file.by_id(self.list_item), "material": self.file.by_id(self.list_item),
}, },
).execute() )
Data.load_lists() Data.load_lists()
return {"FINISHED"} return {"FINISHED"}
@@ -305,13 +305,14 @@ class EditAssignedMaterial(bpy.types.Operator):
attributes = {} attributes = {}
for attribute in props.material_set_attributes: for attribute in props.material_set_attributes:
attributes[attribute.name] = None if attribute.is_null else attribute.string_value attributes[attribute.name] = None if attribute.is_null else attribute.string_value
edit_assigned_material.Usecase( ifcopenshell.api.run(
"material.edit_assigned_material",
self.file, self.file,
{ **{
"element": material_set, "element": material_set,
"attributes": attributes, "attributes": attributes,
}, },
).execute() )
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id) Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
if material_set.is_a("IfcMaterialConstituentSet"): if material_set.is_a("IfcMaterialConstituentSet"):
Data.load_constituents() Data.load_constituents()
@@ -408,34 +409,37 @@ class EditMaterialSetItem(bpy.types.Operator):
attributes[attribute.name] = None if attribute.is_null else value attributes[attribute.name] = None if attribute.is_null else value
if product_data["type"] == "IfcMaterialConstituentSet": if product_data["type"] == "IfcMaterialConstituentSet":
edit_constituent.Usecase( ifcopenshell.api.run(
"material.edit_constituent",
self.file, self.file,
{ **{
"constituent": self.file.by_id(self.material_set_item), "constituent": self.file.by_id(self.material_set_item),
"attributes": attributes, "attributes": attributes,
"material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material_set_item_material)), "material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material_set_item_material)),
}, },
).execute() )
Data.load_constituents() Data.load_constituents()
elif product_data["type"] == "IfcMaterialLayerSet" or product_data["type"] == "IfcMaterialLayerSetUsage": elif product_data["type"] == "IfcMaterialLayerSet" or product_data["type"] == "IfcMaterialLayerSetUsage":
edit_layer.Usecase( ifcopenshell.api.run(
"material.edit_layer",
self.file, self.file,
{ **{
"layer": self.file.by_id(self.material_set_item), "layer": self.file.by_id(self.material_set_item),
"attributes": attributes, "attributes": attributes,
"material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material_set_item_material)), "material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material_set_item_material)),
}, },
).execute() )
Data.load_layers() Data.load_layers()
elif product_data["type"] == "IfcMaterialProfileSet": elif product_data["type"] == "IfcMaterialProfileSet":
edit_profile.Usecase( ifcopenshell.api.run(
"material.edit_profile",
self.file, self.file,
{ **{
"profile": self.file.by_id(self.material_set_item), "profile": self.file.by_id(self.material_set_item),
"attributes": attributes, "attributes": attributes,
"material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material_set_item_material)), "material": self.file.by_id(int(obj.BIMObjectMaterialProperties.material_set_item_material)),
}, },
).execute() )
Data.load_profiles() Data.load_profiles()
else: else:
pass pass
@@ -1,6 +1,5 @@
import bpy import bpy
import ifcopenshell.api.grid.create_grid_axis as create_grid_axis import ifcopenshell.api
import ifcopenshell.api.grid.create_axis_curve as create_axis_curve
from bpy.types import Operator from bpy.types import Operator
from bpy.props import FloatProperty, IntProperty from bpy.props import FloatProperty, IntProperty
from mathutils import Vector from mathutils import Vector
@@ -54,10 +53,12 @@ def add_object(self, context):
axes_collection.objects.link(obj) axes_collection.objects.link(obj)
if self.file: if self.file:
result = create_grid_axis.Usecase( result = ifcopenshell.api.run(
self.file, {"AxisTag": tag, "AxisCurve": obj, "UVWAxes": "UAxes", "Grid": grid} "grid.create_grid_axis",
).execute() self.file,
create_axis_curve.Usecase(self.file, {"AxisCurve": obj, "grid_axis": result}).execute() **{"AxisTag": tag, "AxisCurve": obj, "UVWAxes": "UAxes", "Grid": grid},
)
ifcopenshell.api.run("grid.create_axis_curve", self.file, **{"AxisCurve": obj, "grid_axis": result})
obj.BIMObjectProperties.ifc_definition_id = result.id() obj.BIMObjectProperties.ifc_definition_id = result.id()
axes_collection = bpy.data.collections.new("VAxes") axes_collection = bpy.data.collections.new("VAxes")
@@ -77,10 +78,12 @@ def add_object(self, context):
axes_collection.objects.link(obj) axes_collection.objects.link(obj)
if IfcStore.get_file(): if IfcStore.get_file():
result = create_grid_axis.Usecase( result = ifcopenshell.api.run(
self.file, {"AxisTag": tag, "AxisCurve": obj, "UVWAxes": "VAxes", "Grid": grid} "grid.create_grid_axis",
).execute() self.file,
create_axis_curve.Usecase(self.file, {"AxisCurve": obj, "grid_axis": result}).execute() **{"AxisTag": tag, "AxisCurve": obj, "UVWAxes": "VAxes", "Grid": grid},
)
ifcopenshell.api.run("grid.create_axis_curve", self.file, **{"AxisCurve": obj, "grid_axis": result})
obj.BIMObjectProperties.ifc_definition_id = result.id() obj.BIMObjectProperties.ifc_definition_id = result.id()
@@ -1,17 +1,6 @@
import bpy import bpy
import json import json
import ifcopenshell.api.owner.add_person as add_person import ifcopenshell.api
import ifcopenshell.api.owner.edit_person as edit_person
import ifcopenshell.api.owner.remove_person as remove_person
import ifcopenshell.api.owner.add_organisation as add_organisation
import ifcopenshell.api.owner.edit_organisation as edit_organisation
import ifcopenshell.api.owner.remove_organisation as remove_organisation
import ifcopenshell.api.owner.add_role as add_role
import ifcopenshell.api.owner.edit_role as edit_role
import ifcopenshell.api.owner.remove_role as remove_role
import ifcopenshell.api.owner.add_address as add_address
import ifcopenshell.api.owner.edit_address as edit_address
import ifcopenshell.api.owner.remove_address as remove_address
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.owner.data import Data from ifcopenshell.api.owner.data import Data
@@ -50,7 +39,7 @@ class AddPerson(bpy.types.Operator):
bl_label = "Add Person" bl_label = "Add Person"
def execute(self, context): def execute(self, context):
add_person.Usecase(IfcStore.get_file()).execute() ifcopenshell.api.run("owner.add_person", IfcStore.get_file())
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -73,9 +62,11 @@ class EditPerson(bpy.types.Operator):
if self.file.schema == "IFC2X3": if self.file.schema == "IFC2X3":
attributes["Id"] = attributes["Identification"] attributes["Id"] = attributes["Identification"]
del attributes["Identification"] del attributes["Identification"]
edit_person.Usecase( ifcopenshell.api.run(
self.file, {"person": self.file.by_id(props.active_person_id), "attributes": attributes} "owner.edit_person",
).execute() self.file,
**{"person": self.file.by_id(props.active_person_id), "attributes": attributes}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.disable_editing_person() bpy.ops.bim.disable_editing_person()
return {"FINISHED"} return {"FINISHED"}
@@ -88,7 +79,7 @@ class RemovePerson(bpy.types.Operator):
def execute(self, context): def execute(self, context):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_person.Usecase(self.file, {"person": self.file.by_id(self.person_id)}).execute() ifcopenshell.api.run("owner.remove_person", self.file, **{"person": self.file.by_id(self.person_id)})
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -125,7 +116,9 @@ class AddRole(bpy.types.Operator):
def execute(self, context): def execute(self, context):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
add_role.Usecase(self.file, {"assigned_object": self.file.by_id(self.assigned_object_id)}).execute() ifcopenshell.api.run(
"owner.add_role", self.file, **{"assigned_object": self.file.by_id(self.assigned_object_id)}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -142,9 +135,9 @@ class EditRole(bpy.types.Operator):
"UserDefinedRole": props.role.user_defined_role if props.role.name == "USERDEFINED" else None, "UserDefinedRole": props.role.user_defined_role if props.role.name == "USERDEFINED" else None,
"Description": props.role.description or None, "Description": props.role.description or None,
} }
edit_role.Usecase( ifcopenshell.api.run(
self.file, {"role": self.file.by_id(props.active_role_id), "attributes": attributes} "owner.edit_role", self.file, **{"role": self.file.by_id(props.active_role_id), "attributes": attributes}
).execute() )
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.disable_editing_role() bpy.ops.bim.disable_editing_role()
return {"FINISHED"} return {"FINISHED"}
@@ -157,7 +150,7 @@ class RemoveRole(bpy.types.Operator):
def execute(self, context): def execute(self, context):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_role.Usecase(self.file, {"role": self.file.by_id(self.role_id)}).execute() ifcopenshell.api.run("owner.remove_role", self.file, **{"role": self.file.by_id(self.role_id)})
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -170,9 +163,11 @@ class AddAddress(bpy.types.Operator):
def execute(self, context): def execute(self, context):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
add_address.Usecase( ifcopenshell.api.run(
self.file, {"assigned_object": self.file.by_id(self.assigned_object_id), "ifc_class": self.ifc_class} "owner.add_address",
).execute() self.file,
**{"assigned_object": self.file.by_id(self.assigned_object_id), "ifc_class": self.ifc_class}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -257,16 +252,18 @@ class EditAddress(bpy.types.Operator):
if self.file.schema == "IFC2X3": if self.file.schema == "IFC2X3":
del attributes["MessagingIDs"] del attributes["MessagingIDs"]
elif address.is_a("IfcPostalAddress"): elif address.is_a("IfcPostalAddress"):
attributes.update({ attributes.update(
"InternalLocation": props.address.internal_location or None, {
"AddressLines": json.loads(props.address.address_lines) if props.address.address_lines else None, "InternalLocation": props.address.internal_location or None,
"PostalBox": props.address.postal_box or None, "AddressLines": json.loads(props.address.address_lines) if props.address.address_lines else None,
"Town": props.address.town or None, "PostalBox": props.address.postal_box or None,
"Region": props.address.region or None, "Town": props.address.town or None,
"PostalCode": props.address.postal_code or None, "Region": props.address.region or None,
"Country": props.address.country or None, "PostalCode": props.address.postal_code or None,
}) "Country": props.address.country or None,
edit_address.Usecase(self.file, {"address": address, "attributes": attributes}).execute() }
)
ifcopenshell.api.run("owner.edit_address", self.file, **{"address": address, "attributes": attributes})
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.disable_editing_address() bpy.ops.bim.disable_editing_address()
return {"FINISHED"} return {"FINISHED"}
@@ -279,7 +276,7 @@ class RemoveAddress(bpy.types.Operator):
def execute(self, context): def execute(self, context):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_address.Usecase(self.file, {"address": self.file.by_id(self.address_id)}).execute() ifcopenshell.api.run("owner.remove_address", self.file, **{"address": self.file.by_id(self.address_id)})
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -315,7 +312,7 @@ class AddOrganisation(bpy.types.Operator):
bl_label = "Add Organisation" bl_label = "Add Organisation"
def execute(self, context): def execute(self, context):
add_organisation.Usecase(IfcStore.get_file()).execute() ifcopenshell.api.run("owner.add_organisation", IfcStore.get_file())
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -335,9 +332,11 @@ class EditOrganisation(bpy.types.Operator):
if self.file.schema == "IFC2X3": if self.file.schema == "IFC2X3":
attributes["Id"] = attributes["Identification"] attributes["Id"] = attributes["Identification"]
del attributes["Identification"] del attributes["Identification"]
edit_organisation.Usecase( ifcopenshell.api.run(
self.file, {"organisation": self.file.by_id(props.active_organisation_id), "attributes": attributes} "owner.edit_organisation",
).execute() self.file,
**{"organisation": self.file.by_id(props.active_organisation_id), "attributes": attributes}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.disable_editing_organisation() bpy.ops.bim.disable_editing_organisation()
return {"FINISHED"} return {"FINISHED"}
@@ -350,6 +349,8 @@ class RemoveOrganisation(bpy.types.Operator):
def execute(self, context): def execute(self, context):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_organisation.Usecase(self.file, {"organisation": self.file.by_id(self.organisation_id)}).execute() ifcopenshell.api.run(
"owner.remove_organisation", self.file, **{"organisation": self.file.by_id(self.organisation_id)}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -1,7 +1,7 @@
import bpy import bpy
import logging import logging
import ifcopenshell import ifcopenshell
import ifcopenshell.api.project.create_file as create_file import ifcopenshell.api
import bpy import bpy
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
@@ -17,7 +17,9 @@ class CreateProject(bpy.types.Operator):
if self.file: if self.file:
return {"FINISHED"} return {"FINISHED"}
IfcStore.file = create_file.Usecase({"version": bpy.context.scene.BIMProperties.export_schema}).execute() IfcStore.file = ifcopenshell.api.run(
"project.create_file", **{"version": bpy.context.scene.BIMProperties.export_schema}
)
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
bpy.ops.bim.add_person() bpy.ops.bim.add_person()
@@ -1,11 +1,7 @@
import bpy import bpy
import json import json
import ifcopenshell.api
import ifcopenshell.util.unit import ifcopenshell.util.unit
import ifcopenshell.api.pset.add_pset as add_pset
import ifcopenshell.api.pset.edit_pset as edit_pset
import ifcopenshell.api.pset.remove_pset as remove_pset
import ifcopenshell.api.pset.add_qto as add_qto
import ifcopenshell.api.pset.edit_qto as edit_qto
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.pset.data import Data from ifcopenshell.api.pset.data import Data
from blenderbim.bim.module.pset.qto_calculator import QtoCalculator from blenderbim.bim.module.pset.qto_calculator import QtoCalculator
@@ -120,23 +116,25 @@ class EditPset(bpy.types.Operator):
properties[prop["Name"]] = blender_prop.enum_value properties[prop["Name"]] = blender_prop.enum_value
if pset_id in Data.psets: if pset_id in Data.psets:
edit_pset.Usecase( ifcopenshell.api.run(
"pset.edit_pset",
self.file, self.file,
{ **{
"pset": self.file.by_id(pset_id), "pset": self.file.by_id(pset_id),
"Name": props.active_pset_name, "Name": props.active_pset_name,
"Properties": properties, "Properties": properties,
}, },
).execute() )
else: else:
edit_qto.Usecase( ifcopenshell.api.run(
"pset.edit_qto",
self.file, self.file,
{ **{
"qto": self.file.by_id(pset_id), "qto": self.file.by_id(pset_id),
"Name": props.active_pset_name, "Name": props.active_pset_name,
"Properties": properties, "Properties": properties,
}, },
).execute() )
Data.load(IfcStore.get_file(), oprops.ifc_definition_id) Data.load(IfcStore.get_file(), oprops.ifc_definition_id)
bpy.ops.bim.disable_pset_editing(obj=self.obj, obj_type=self.obj_type) bpy.ops.bim.disable_pset_editing(obj=self.obj, obj_type=self.obj_type)
return {"FINISHED"} return {"FINISHED"}
@@ -156,13 +154,14 @@ class RemovePset(bpy.types.Operator):
elif self.obj_type == "Material": elif self.obj_type == "Material":
obj = bpy.data.materials.get(self.obj) obj = bpy.data.materials.get(self.obj)
props = obj.BIMObjectProperties props = obj.BIMObjectProperties
remove_pset.Usecase( ifcopenshell.api.run(
"pset.remove_pset",
self.file, self.file,
{ **{
"product": self.file.by_id(props.ifc_definition_id), "product": self.file.by_id(props.ifc_definition_id),
"pset": self.file.by_id(self.pset_id), "pset": self.file.by_id(self.pset_id),
}, },
).execute() )
Data.load(IfcStore.get_file(), props.ifc_definition_id) Data.load(IfcStore.get_file(), props.ifc_definition_id)
return {"FINISHED"} return {"FINISHED"}
@@ -190,13 +189,14 @@ class AddPset(bpy.types.Operator):
elif self.obj_type == "Material": elif self.obj_type == "Material":
pset_name = props.material_pset_name pset_name = props.material_pset_name
add_pset.Usecase( ifcopenshell.api.run(
"pset.add_pset",
self.file, self.file,
{ **{
"product": self.file.by_id(oprops.ifc_definition_id), "product": self.file.by_id(oprops.ifc_definition_id),
"Name": pset_name, "Name": pset_name,
}, },
).execute() )
Data.load(IfcStore.get_file(), oprops.ifc_definition_id) Data.load(IfcStore.get_file(), oprops.ifc_definition_id)
return {"FINISHED"} return {"FINISHED"}
@@ -210,13 +210,14 @@ class AddQto(bpy.types.Operator):
obj = bpy.context.active_object obj = bpy.context.active_object
oprops = obj.BIMObjectProperties oprops = obj.BIMObjectProperties
props = obj.PsetProperties props = obj.PsetProperties
add_qto.Usecase( ifcopenshell.api.run(
"pset.add_qto",
self.file, self.file,
{ **{
"product": self.file.by_id(oprops.ifc_definition_id), "product": self.file.by_id(oprops.ifc_definition_id),
"Name": props.qto_name, "Name": props.qto_name,
}, },
).execute() )
Data.load(IfcStore.get_file(), oprops.ifc_definition_id) Data.load(IfcStore.get_file(), oprops.ifc_definition_id)
return {"FINISHED"} return {"FINISHED"}
@@ -1,11 +1,6 @@
import bpy import bpy
import ifcopenshell import ifcopenshell
import ifcopenshell.api.pset_template.add_pset_template as add_pset_template import ifcopenshell.api
import ifcopenshell.api.pset_template.edit_pset_template as edit_pset_template
import ifcopenshell.api.pset_template.remove_pset_template as remove_pset_template
import ifcopenshell.api.pset_template.add_prop_template as add_prop_template
import ifcopenshell.api.pset_template.edit_prop_template as edit_prop_template
import ifcopenshell.api.pset_template.remove_prop_template as remove_prop_template
from blenderbim.bim.module.pset_template.prop import updatePsetTemplateFiles, updatePsetTemplates from blenderbim.bim.module.pset_template.prop import updatePsetTemplateFiles, updatePsetTemplates
from ifcopenshell.api.pset_template.data import Data from ifcopenshell.api.pset_template.data import Data
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
@@ -17,7 +12,7 @@ class AddPsetTemplate(bpy.types.Operator):
def execute(self, context): def execute(self, context):
props = context.scene.BIMPsetTemplateProperties props = context.scene.BIMPsetTemplateProperties
add_pset_template.Usecase(IfcStore.pset_template_file).execute() ifcopenshell.api.run("pset_template.add_pset_template", IfcStore.pset_template_file)
Data.load(IfcStore.pset_template_file) Data.load(IfcStore.pset_template_file)
updatePsetTemplates(self, context) updatePsetTemplates(self, context)
return {"FINISHED"} return {"FINISHED"}
@@ -31,9 +26,9 @@ class RemovePsetTemplate(bpy.types.Operator):
props = context.scene.BIMPsetTemplateProperties props = context.scene.BIMPsetTemplateProperties
if props.active_pset_template_id == int(props.pset_templates): if props.active_pset_template_id == int(props.pset_templates):
bpy.ops.bim.disable_editing_pset_template() bpy.ops.bim.disable_editing_pset_template()
remove_pset_template.Usecase(IfcStore.pset_template_file, { ifcopenshell.api.run("pset_template.remove_pset_template", IfcStore.pset_template_file, **{
"pset_template": IfcStore.pset_template_file.by_id(int(props.pset_templates)) "pset_template": IfcStore.pset_template_file.by_id(int(props.pset_templates))
}).execute() })
Data.load(IfcStore.pset_template_file) Data.load(IfcStore.pset_template_file)
updatePsetTemplates(self, context) updatePsetTemplates(self, context)
return {"FINISHED"} return {"FINISHED"}
@@ -96,7 +91,7 @@ class EditPsetTemplate(bpy.types.Operator):
def execute(self, context): def execute(self, context):
props = context.scene.BIMPsetTemplateProperties props = context.scene.BIMPsetTemplateProperties
edit_pset_template.Usecase(IfcStore.pset_template_file, { ifcopenshell.api.run("pset_template.edit_pset_template", IfcStore.pset_template_file, **{
"pset_template": IfcStore.pset_template_file.by_id(props.active_pset_template_id), "pset_template": IfcStore.pset_template_file.by_id(props.active_pset_template_id),
"attributes": { "attributes": {
"Name": props.active_pset_template.name, "Name": props.active_pset_template.name,
@@ -104,7 +99,7 @@ class EditPsetTemplate(bpy.types.Operator):
"TemplateType": props.active_pset_template.template_type, "TemplateType": props.active_pset_template.template_type,
"ApplicableEntity": props.active_pset_template.applicable_entity, "ApplicableEntity": props.active_pset_template.applicable_entity,
} }
}).execute() })
Data.load(IfcStore.pset_template_file) Data.load(IfcStore.pset_template_file)
updatePsetTemplates(self, context) updatePsetTemplates(self, context)
bpy.ops.bim.disable_editing_pset_template() bpy.ops.bim.disable_editing_pset_template()
@@ -127,9 +122,9 @@ class AddPropTemplate(bpy.types.Operator):
def execute(self, context): def execute(self, context):
props = context.scene.BIMPsetTemplateProperties props = context.scene.BIMPsetTemplateProperties
pset_template_id = props.active_pset_template_id or int(props.pset_templates) pset_template_id = props.active_pset_template_id or int(props.pset_templates)
add_prop_template.Usecase(IfcStore.pset_template_file, { ifcopenshell.api.run("pset_template.add_prop_template", IfcStore.pset_template_file, **{
"pset_template": IfcStore.pset_template_file.by_id(pset_template_id) "pset_template": IfcStore.pset_template_file.by_id(pset_template_id)
}).execute() })
Data.load(IfcStore.pset_template_file) Data.load(IfcStore.pset_template_file)
return {"FINISHED"} return {"FINISHED"}
@@ -141,9 +136,9 @@ class RemovePropTemplate(bpy.types.Operator):
def execute(self, context): def execute(self, context):
props = context.scene.BIMPsetTemplateProperties props = context.scene.BIMPsetTemplateProperties
remove_prop_template.Usecase(IfcStore.pset_template_file, { ifcopenshell.api.run("pset_template.remove_prop_template", IfcStore.pset_template_file, **{
"prop_template": IfcStore.pset_template_file.by_id(self.prop_template) "prop_template": IfcStore.pset_template_file.by_id(self.prop_template)
}).execute() })
Data.load(IfcStore.pset_template_file) Data.load(IfcStore.pset_template_file)
return {"FINISHED"} return {"FINISHED"}
@@ -154,14 +149,14 @@ class EditPropTemplate(bpy.types.Operator):
def execute(self, context): def execute(self, context):
props = context.scene.BIMPsetTemplateProperties props = context.scene.BIMPsetTemplateProperties
edit_prop_template.Usecase(IfcStore.pset_template_file, { ifcopenshell.api.run("pset_template.edit_prop_template", IfcStore.pset_template_file, **{
"prop_template": IfcStore.pset_template_file.by_id(props.active_prop_template_id), "prop_template": IfcStore.pset_template_file.by_id(props.active_prop_template_id),
"attributes": { "attributes": {
"Name": props.active_prop_template.name, "Name": props.active_prop_template.name,
"Description": props.active_prop_template.description, "Description": props.active_prop_template.description,
"PrimaryMeasureType": props.active_prop_template.primary_measure_type, "PrimaryMeasureType": props.active_prop_template.primary_measure_type,
} }
}).execute() })
Data.load(IfcStore.pset_template_file) Data.load(IfcStore.pset_template_file)
bpy.ops.bim.disable_editing_prop_template() bpy.ops.bim.disable_editing_prop_template()
return {"FINISHED"} return {"FINISHED"}
@@ -1,12 +1,9 @@
import bpy import bpy
import numpy as np import numpy as np
import ifcopenshell import ifcopenshell
import ifcopenshell.api
import ifcopenshell.util.schema import ifcopenshell.util.schema
import ifcopenshell.util.element import ifcopenshell.util.element
import ifcopenshell.api.root.create_product as create_product
import ifcopenshell.api.root.remove_product as remove_product
import ifcopenshell.api.root.reassign_class as reassign_class
import ifcopenshell.api.root.copy_class as copy_class
from ifcopenshell.api.geometry.data import Data as GeometryData from ifcopenshell.api.geometry.data import Data as GeometryData
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
@@ -61,14 +58,15 @@ class ReassignClass(bpy.types.Operator):
if predefined_type == "USERDEFINED": if predefined_type == "USERDEFINED":
predefined_type = bpy.context.scene.BIMRootProperties.ifc_userdefined_type predefined_type = bpy.context.scene.BIMRootProperties.ifc_userdefined_type
for obj in objects: for obj in objects:
product = reassign_class.Usecase( product = ifcopenshell.api.run(
"root.reassign_class",
self.file, self.file,
{ **{
"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id), "product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id),
"ifc_class": bpy.context.scene.BIMRootProperties.ifc_class, "ifc_class": bpy.context.scene.BIMRootProperties.ifc_class,
"predefined_type": predefined_type, "predefined_type": predefined_type,
}, },
).execute() )
obj.name = "{}/{}".format(product.is_a(), "/".join(obj.name.split("/")[1:])) obj.name = "{}/{}".format(product.is_a(), "/".join(obj.name.split("/")[1:]))
IfcStore.link_element(product, obj) IfcStore.link_element(product, obj)
obj.BIMObjectProperties.is_reassigning_class = False obj.BIMObjectProperties.is_reassigning_class = False
@@ -103,14 +101,15 @@ class AssignClass(bpy.types.Operator):
def assign_class(self, context, obj): def assign_class(self, context, obj):
if obj.BIMObjectProperties.ifc_definition_id: if obj.BIMObjectProperties.ifc_definition_id:
return return
product = create_product.Usecase( product = ifcopenshell.api.run(
"root.create_entity",
self.file, self.file,
{ **{
"ifc_class": self.ifc_class, "ifc_class": self.ifc_class,
"predefined_type": self.predefined_type, "predefined_type": self.predefined_type,
"name": obj.name, "name": obj.name,
}, },
).execute() )
obj.name = "{}/{}".format(product.is_a(), obj.name) obj.name = "{}/{}".format(product.is_a(), obj.name)
IfcStore.link_element(product, obj) IfcStore.link_element(product, obj)
@@ -185,7 +184,7 @@ class UnassignClass(bpy.types.Operator):
continue continue
product = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id) product = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
IfcStore.unlink_element(product, obj) IfcStore.unlink_element(product, obj)
remove_product.Usecase(self.file, {"product": product}).execute() ifcopenshell.api.run("root.remove_product", self.file, **{"product": product})
if "/" in obj.name and obj.name[0:3] == "Ifc": if "/" in obj.name and obj.name[0:3] == "Ifc":
obj.name = "/".join(obj.name.split("/")[1:]) obj.name = "/".join(obj.name.split("/")[1:])
if obj.data and obj.data.name == "Void": if obj.data and obj.data.name == "Void":
@@ -226,9 +225,9 @@ class CopyClass(bpy.types.Operator):
for obj in objects: for obj in objects:
if not obj.BIMObjectProperties.ifc_definition_id: if not obj.BIMObjectProperties.ifc_definition_id:
continue continue
result = copy_class.Usecase( result = ifcopenshell.api.run(
self.file, {"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)} "root.copy_class", self.file, **{"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)}
).execute() )
IfcStore.link_element(result, obj) IfcStore.link_element(result, obj)
relating_type = ifcopenshell.util.element.get_type(result) relating_type = ifcopenshell.util.element.get_type(result)
if relating_type and relating_type.RepresentationMaps: if relating_type and relating_type.RepresentationMaps:
@@ -1,6 +1,5 @@
import bpy import bpy
import ifcopenshell.api.spatial.assign_container as assign_container import ifcopenshell.api
import ifcopenshell.api.spatial.remove_container as remove_container
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.spatial.data import Data from ifcopenshell.api.spatial.data import Data
from blenderbim.bim.module.spatial.prop import getSpatialContainers from blenderbim.bim.module.spatial.prop import getSpatialContainers
@@ -24,13 +23,14 @@ class AssignContainer(bpy.types.Operator):
self.relating_structure or sprops.spatial_elements[sprops.active_spatial_element_index].ifc_definition_id self.relating_structure or sprops.spatial_elements[sprops.active_spatial_element_index].ifc_definition_id
) )
assign_container.Usecase( ifcopenshell.api.run(
"spatial.assign_container",
self.file, self.file,
{ **{
"product": self.file.by_id(oprops.ifc_definition_id), "product": self.file.by_id(oprops.ifc_definition_id),
"relating_structure": self.file.by_id(relating_structure), "relating_structure": self.file.by_id(relating_structure),
}, },
).execute() )
bpy.ops.bim.edit_object_placement(obj=related_element.name) bpy.ops.bim.edit_object_placement(obj=related_element.name)
Data.load(IfcStore.get_file(), oprops.ifc_definition_id) Data.load(IfcStore.get_file(), oprops.ifc_definition_id)
bpy.ops.bim.disable_editing_container(obj=related_element.name) bpy.ops.bim.disable_editing_container(obj=related_element.name)
@@ -100,7 +100,9 @@ class RemoveContainer(bpy.types.Operator):
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
oprops = obj.BIMObjectProperties oprops = obj.BIMObjectProperties
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_container.Usecase(self.file, {"product": self.file.by_id(oprops.ifc_definition_id)}).execute() ifcopenshell.api.run(
"spatial.remove_container", self.file, **{"product": self.file.by_id(oprops.ifc_definition_id)}
)
Data.load(IfcStore.get_file(), oprops.ifc_definition_id) Data.load(IfcStore.get_file(), oprops.ifc_definition_id)
aggregate_collection = bpy.data.collections.get(obj.name) aggregate_collection = bpy.data.collections.get(obj.name)
@@ -1,14 +1,7 @@
import bpy import bpy
import json import json
import ifcopenshell import ifcopenshell
import ifcopenshell.api.structural.add_structural_boundary_condition as add_structural_boundary_condition import ifcopenshell.api
import ifcopenshell.api.structural.edit_structural_boundary_condition as edit_structural_boundary_condition
import ifcopenshell.api.structural.remove_structural_boundary_condition as remove_structural_boundary_condition
import ifcopenshell.api.structural.add_structural_analysis_model as add_structural_analysis_model
import ifcopenshell.api.structural.edit_structural_analysis_model as edit_structural_analysis_model
import ifcopenshell.api.structural.remove_structural_analysis_model as remove_structural_analysis_model
import ifcopenshell.api.structural.assign_structural_analysis_model as assign_structural_analysis_model
import ifcopenshell.api.structural.unassign_structural_analysis_model as unassign_structural_analysis_model
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.structural.data import Data from ifcopenshell.api.structural.data import Data
@@ -21,7 +14,7 @@ class AddStructuralBoundaryCondition(bpy.types.Operator):
obj = context.active_object obj = context.active_object
file = IfcStore.get_file() file = IfcStore.get_file()
connection = file.by_id(obj.BIMObjectProperties.ifc_definition_id) connection = file.by_id(obj.BIMObjectProperties.ifc_definition_id)
add_structural_boundary_condition.Usecase(file, {"connection": connection}).execute() ifcopenshell.api.run("structural.add_structural_boundary_condition", file, **{"connection": connection})
Data.load(IfcStore.get_file(), connection.id()) Data.load(IfcStore.get_file(), connection.id())
return {"FINISHED"} return {"FINISHED"}
@@ -34,7 +27,7 @@ class RemoveStructuralBoundaryCondition(bpy.types.Operator):
obj = context.active_object obj = context.active_object
file = IfcStore.get_file() file = IfcStore.get_file()
connection = file.by_id(obj.BIMObjectProperties.ifc_definition_id) connection = file.by_id(obj.BIMObjectProperties.ifc_definition_id)
remove_structural_boundary_condition.Usecase(file, {"connection": connection}).execute() ifcopenshell.api.run("structural.remove_structural_boundary_condition", file, **{"connection": connection})
Data.load(IfcStore.get_file(), connection.id()) Data.load(IfcStore.get_file(), connection.id())
return {"FINISHED"} return {"FINISHED"}
@@ -102,7 +95,9 @@ class EditStructuralBoundaryCondition(bpy.types.Operator):
else: else:
attributes[attribute.name] = {"value": attribute.float_value, "type": attribute.enum_value} attributes[attribute.name] = {"value": attribute.float_value, "type": attribute.enum_value}
edit_structural_boundary_condition.Usecase(file, {"condition": condition, "attributes": attributes}).execute() ifcopenshell.api.run(
"structural.edit_structural_boundary_condition", file, **{"condition": condition, "attributes": attributes}
)
Data.load(IfcStore.get_file(), connection.id()) Data.load(IfcStore.get_file(), connection.id())
bpy.ops.bim.disable_editing_structural_boundary_condition() bpy.ops.bim.disable_editing_structural_boundary_condition()
return {"FINISHED"} return {"FINISHED"}
@@ -148,7 +143,7 @@ class AddStructuralAnalysisModel(bpy.types.Operator):
bl_label = "Add Structural Analysis Model" bl_label = "Add Structural Analysis Model"
def execute(self, context): def execute(self, context):
result = add_structural_analysis_model.Usecase(IfcStore.get_file()).execute() result = ifcopenshell.api.run("structural.add_structural_analysis_model", IfcStore.get_file())
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_structural_analysis_models() bpy.ops.bim.load_structural_analysis_models()
bpy.ops.bim.enable_editing_structural_analysis_model(structural_analysis_model=result.id()) bpy.ops.bim.enable_editing_structural_analysis_model(structural_analysis_model=result.id())
@@ -171,9 +166,14 @@ class EditStructuralAnalysisModel(bpy.types.Operator):
elif attribute.data_type == "enum": elif attribute.data_type == "enum":
attributes[attribute.name] = attribute.enum_value attributes[attribute.name] = attribute.enum_value
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
edit_structural_analysis_model.Usecase( ifcopenshell.api.run(
self.file, {"structural_analysis_model": self.file.by_id(props.active_structural_analysis_model_id), "attributes": attributes} "structural.edit_structural_analysis_model",
).execute() self.file,
**{
"structural_analysis_model": self.file.by_id(props.active_structural_analysis_model_id),
"attributes": attributes,
}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_structural_analysis_models() bpy.ops.bim.load_structural_analysis_models()
return {"FINISHED"} return {"FINISHED"}
@@ -187,7 +187,11 @@ class RemoveStructuralAnalysisModel(bpy.types.Operator):
def execute(self, context): def execute(self, context):
props = context.scene.BIMStructuralProperties props = context.scene.BIMStructuralProperties
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_structural_analysis_model.Usecase(self.file, {"structural_analysis_model": self.file.by_id(self.structural_analysis_model)}).execute() ifcopenshell.api.run(
"structural.remove_structural_analysis_model",
self.file,
**{"structural_analysis_model": self.file.by_id(self.structural_analysis_model)}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
bpy.ops.bim.load_structural_analysis_models() bpy.ops.bim.load_structural_analysis_models()
return {"FINISHED"} return {"FINISHED"}
@@ -243,10 +247,14 @@ class AssignStructuralAnalysisModel(bpy.types.Operator):
def execute(self, context): def execute(self, context):
product = bpy.data.objects.get(self.product) if self.product else context.active_object product = bpy.data.objects.get(self.product) if self.product else context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
assign_structural_analysis_model.Usecase(self.file, { ifcopenshell.api.run(
"product": self.file.by_id(product.BIMObjectProperties.ifc_definition_id), "structural.assign_structural_analysis_model",
"structural_analysis_model": self.file.by_id(self.structural_analysis_model) self.file,
}).execute() **{
"product": self.file.by_id(product.BIMObjectProperties.ifc_definition_id),
"structural_analysis_model": self.file.by_id(self.structural_analysis_model),
}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -260,9 +268,13 @@ class UnassignStructuralAnalysisModel(bpy.types.Operator):
def execute(self, context): def execute(self, context):
product = bpy.data.objects.get(self.product) if self.product else context.active_object product = bpy.data.objects.get(self.product) if self.product else context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
unassign_structural_analysis_model.Usecase(self.file, { ifcopenshell.api.run(
"product": self.file.by_id(product.BIMObjectProperties.ifc_definition_id), "structural.unassign_structural_analysis_model",
"structural_analysis_model": self.file.by_id(self.structural_analysis_model) self.file,
}).execute() **{
"product": self.file.by_id(product.BIMObjectProperties.ifc_definition_id),
"structural_analysis_model": self.file.by_id(self.structural_analysis_model),
}
)
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -1,6 +1,5 @@
import bpy import bpy
import ifcopenshell.api.style.add_style as add_style import ifcopenshell.api
import ifcopenshell.api.style.edit_style as edit_style
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
@@ -28,7 +27,7 @@ class EditStyle(bpy.types.Operator):
material = bpy.data.objects.get(self.material) if self.material else bpy.context.active_object.active_material material = bpy.data.objects.get(self.material) if self.material else bpy.context.active_object.active_material
settings = get_colour_settings(material) settings = get_colour_settings(material)
settings["style"] = self.file.by_id(material.BIMMaterialProperties.ifc_style_id) settings["style"] = self.file.by_id(material.BIMMaterialProperties.ifc_style_id)
edit_style.Usecase(self.file, settings).execute() ifcopenshell.api.run("style.edit_style", self.file, **settings)
return {"FINISHED"} return {"FINISHED"}
@@ -43,7 +42,7 @@ class AddStyle(bpy.types.Operator):
settings = get_colour_settings(material) settings = get_colour_settings(material)
settings["Name"] = material.name settings["Name"] = material.name
settings["external_definition"] = None # TODO: Implement. See #1222 settings["external_definition"] = None # TODO: Implement. See #1222
style = add_style.Usecase(self.file, settings).execute() style = ifcopenshell.api.run("style.add_style", self.file, **settings)
material.BIMMaterialProperties.ifc_style_id = int(style.id()) material.BIMMaterialProperties.ifc_style_id = int(style.id())
return {"FINISHED"} return {"FINISHED"}
@@ -1,9 +1,7 @@
import bpy import bpy
import ifcopenshell.util.schema import ifcopenshell.util.schema
import ifcopenshell.util.type import ifcopenshell.util.type
import ifcopenshell.api.type.assign_type as assign_type import ifcopenshell.api
import ifcopenshell.api.type.unassign_type as unassign_type
import ifcopenshell.api.type.get_related_objects as get_related_objects
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.type.data import Data from ifcopenshell.api.type.data import Data
from blenderbim.bim.module.type.prop import getIfcTypes, getAvailableTypes, updateTypeInstanceIfcClass from blenderbim.bim.module.type.prop import getIfcTypes, getAvailableTypes, updateTypeInstanceIfcClass
@@ -24,13 +22,14 @@ class AssignType(bpy.types.Operator):
) )
for related_object in related_objects: for related_object in related_objects:
oprops = related_object.BIMObjectProperties oprops = related_object.BIMObjectProperties
assign_type.Usecase( ifcopenshell.api.run(
"type.assign_type",
self.file, self.file,
{ **{
"related_object": self.file.by_id(oprops.ifc_definition_id), "related_object": self.file.by_id(oprops.ifc_definition_id),
"relating_type": self.file.by_id(relating_type), "relating_type": self.file.by_id(relating_type),
}, },
).execute() )
Data.load(IfcStore.get_file(), oprops.ifc_definition_id) Data.load(IfcStore.get_file(), oprops.ifc_definition_id)
if self.file.by_id(relating_type).RepresentationMaps: if self.file.by_id(relating_type).RepresentationMaps:
bpy.ops.bim.map_representations(product_id=oprops.ifc_definition_id, type_product_id=relating_type) bpy.ops.bim.map_representations(product_id=oprops.ifc_definition_id, type_product_id=relating_type)
@@ -51,12 +50,13 @@ class UnassignType(bpy.types.Operator):
) )
for related_object in related_objects: for related_object in related_objects:
oprops = related_object.BIMObjectProperties oprops = related_object.BIMObjectProperties
unassign_type.Usecase( ifcopenshell.api.run(
"type.unassign_type",
self.file, self.file,
{ **{
"related_object": self.file.by_id(oprops.ifc_definition_id), "related_object": self.file.by_id(oprops.ifc_definition_id),
}, },
).execute() )
Data.load(IfcStore.get_file(), oprops.ifc_definition_id) Data.load(IfcStore.get_file(), oprops.ifc_definition_id)
return {"FINISHED"} return {"FINISHED"}
@@ -93,13 +93,13 @@ class SelectSimilarType(bpy.types.Operator):
product = self.file.by_id(oprops.ifc_definition_id) product = self.file.by_id(oprops.ifc_definition_id)
declaration = IfcStore.get_schema().declaration_by_name(product.is_a()) declaration = IfcStore.get_schema().declaration_by_name(product.is_a())
if ifcopenshell.util.schema.is_a(declaration, "IfcElementType"): if ifcopenshell.util.schema.is_a(declaration, "IfcElementType"):
related_objects = get_related_objects.Usecase( related_objects = ifcopenshell.api.run(
self.file, {"relating_type": self.file.by_id(oprops.ifc_definition_id)} "type.get_related_objects", self.file, **{"relating_type": self.file.by_id(oprops.ifc_definition_id)}
).execute() )
else: else:
related_objects = get_related_objects.Usecase( related_objects = ifcopenshell.api.run(
self.file, {"related_object": self.file.by_id(oprops.ifc_definition_id)} "type.get_related_objects", self.file, **{"related_object": self.file.by_id(oprops.ifc_definition_id)}
).execute() )
for obj in bpy.context.visible_objects: for obj in bpy.context.visible_objects:
if obj.BIMObjectProperties.ifc_definition_id in related_objects: if obj.BIMObjectProperties.ifc_definition_id in related_objects:
obj.select_set(True) obj.select_set(True)
@@ -1,5 +1,5 @@
import bpy import bpy
import ifcopenshell.api.unit.assign_unit as assign_unit import ifcopenshell.api
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.unit.data import Data from ifcopenshell.api.unit.data import Data
@@ -9,7 +9,7 @@ class AssignUnit(bpy.types.Operator):
bl_label = "Assign Unit" bl_label = "Assign Unit"
def execute(self, context): def execute(self, context):
assign_unit.Usecase(IfcStore.get_file(), self.get_units()).execute() ifcopenshell.api.run("unit.assign_unit", IfcStore.get_file(), **self.get_units())
Data.load(IfcStore.get_file()) Data.load(IfcStore.get_file())
return {"FINISHED"} return {"FINISHED"}
@@ -1,8 +1,5 @@
import bpy import bpy
import ifcopenshell.api.void.add_opening as add_opening import ifcopenshell.api
import ifcopenshell.api.void.remove_opening as remove_opening
import ifcopenshell.api.void.add_filling as add_filling
import ifcopenshell.api.void.remove_filling as remove_filling
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.void.data import Data from ifcopenshell.api.void.data import Data
from ifcopenshell.api.context.data import Data as ContextData from ifcopenshell.api.context.data import Data as ContextData
@@ -33,13 +30,14 @@ class AddOpening(bpy.types.Operator):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
element_id = obj.BIMObjectProperties.ifc_definition_id element_id = obj.BIMObjectProperties.ifc_definition_id
add_opening.Usecase( ifcopenshell.api.run(
"void.add_opening",
self.file, self.file,
{ **{
"opening": self.file.by_id(opening.BIMObjectProperties.ifc_definition_id), "opening": self.file.by_id(opening.BIMObjectProperties.ifc_definition_id),
"element": self.file.by_id(element_id), "element": self.file.by_id(element_id),
}, },
).execute() )
Data.load(IfcStore.get_file(), element_id) Data.load(IfcStore.get_file(), element_id)
has_modifier = False has_modifier = False
@@ -75,7 +73,7 @@ class RemoveOpening(bpy.types.Operator):
obj.modifiers.remove(modifier) obj.modifiers.remove(modifier)
break break
remove_opening.Usecase(self.file, {"opening": self.file.by_id(self.opening_id)}).execute() ifcopenshell.api.run("void.remove_opening", self.file, **{"opening": self.file.by_id(self.opening_id)})
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id) Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
return {"FINISHED"} return {"FINISHED"}
@@ -91,13 +89,14 @@ class AddFilling(bpy.types.Operator):
opening = bpy.data.objects.get(self.opening) if self.opening else context.scene.VoidProperties.desired_opening opening = bpy.data.objects.get(self.opening) if self.opening else context.scene.VoidProperties.desired_opening
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
element_id = obj.BIMObjectProperties.ifc_definition_id element_id = obj.BIMObjectProperties.ifc_definition_id
add_filling.Usecase( ifcopenshell.api.run(
"void.add_filling",
self.file, self.file,
{ **{
"opening": self.file.by_id(opening.BIMObjectProperties.ifc_definition_id), "opening": self.file.by_id(opening.BIMObjectProperties.ifc_definition_id),
"element": self.file.by_id(element_id), "element": self.file.by_id(element_id),
}, },
).execute() )
Data.load(IfcStore.get_file(), element_id) Data.load(IfcStore.get_file(), element_id)
return {"FINISHED"} return {"FINISHED"}
@@ -110,8 +109,8 @@ class RemoveFilling(bpy.types.Operator):
def execute(self, context): def execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
remove_filling.Usecase( ifcopenshell.api.run(
self.file, {"element": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)} "void.remove_filling", self.file, **{"element": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)}
).execute() )
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id) Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
return {"FINISHED"} return {"FINISHED"}
@@ -0,0 +1,11 @@
import importlib
import ifcopenshell.api
def run(usecase_path, ifc_file=None, **settings):
importlib.import_module(f"ifcopenshell.api.{usecase_path}")
module, usecase = usecase_path.split(".")
usecase_class = getattr(getattr(getattr(ifcopenshell.api, module), usecase), "Usecase")
if ifc_file:
return usecase_class(ifc_file, **settings).execute()
return usecase_class(**settings).execute()
@@ -1,6 +1,5 @@
import ifcopenshell import ifcopenshell
import ifcopenshell.api.owner.create_owner_history as create_owner_history import ifcopenshell.api
import ifcopenshell.api.owner.update_owner_history as update_owner_history
class Usecase: class Usecase:
@@ -32,7 +31,7 @@ class Usecase:
related_objects.remove(self.settings["product"]) related_objects.remove(self.settings["product"])
if related_objects: if related_objects:
decomposes.RelatedObjects = related_objects decomposes.RelatedObjects = related_objects
update_owner_history.Usecase(self.file, {"element": decomposes}).execute() ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": decomposes})
else: else:
self.file.remove(decomposes) self.file.remove(decomposes)
@@ -40,13 +39,13 @@ class Usecase:
related_objects = list(is_decomposed_by.RelatedObjects) related_objects = list(is_decomposed_by.RelatedObjects)
related_objects.append(self.settings["product"]) related_objects.append(self.settings["product"])
is_decomposed_by.RelatedObjects = related_objects is_decomposed_by.RelatedObjects = related_objects
update_owner_history.Usecase(self.file, {"element": is_decomposed_by}).execute() ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": is_decomposed_by})
else: else:
is_decomposed_by = self.file.create_entity( is_decomposed_by = self.file.create_entity(
"IfcRelAggregates", "IfcRelAggregates",
**{ **{
"GlobalId": ifcopenshell.guid.new(), "GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": create_owner_history.Usecase(self.file).execute(), "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
"RelatedObjects": [self.settings["product"]], "RelatedObjects": [self.settings["product"]],
"RelatingObject": self.settings["relating_object"], "RelatingObject": self.settings["relating_object"],
} }
@@ -1,13 +1,10 @@
import ifcopenshell.api.owner.update_owner_history as update_owner_history import ifcopenshell.api
class Usecase(): class Usecase:
def __init__(self, file, **settings): def __init__(self, file, **settings):
self.file = file self.file = file
self.settings = { self.settings = {"product": None, "attributes": {}}
"product": None,
"attributes": {}
}
for key, value in settings.items(): for key, value in settings.items():
self.settings[key] = value self.settings[key] = value
@@ -15,4 +12,4 @@ class Usecase():
for name, value in self.settings["attributes"].items(): for name, value in self.settings["attributes"].items():
setattr(self.settings["product"], name, value) setattr(self.settings["product"], name, value)
if hasattr(self.settings["product"], "OwnerHistory"): if hasattr(self.settings["product"], "OwnerHistory"):
update_owner_history.Usecase(self.file, {"element": self.settings["product"]}).execute() ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": self.settings["product"]})
@@ -1,4 +1,4 @@
import ifcopenshell.api.owner.update_owner_history as update_owner_history import ifcopenshell.api
class Usecase: class Usecase:
@@ -35,4 +35,4 @@ class Usecase:
) )
) )
self.settings["product"].RepresentationMaps = maps self.settings["product"].RepresentationMaps = maps
update_owner_history.Usecase(self.file, {"element": self.settings["product"]}).execute() ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": self.settings["product"]})
@@ -1,7 +1,7 @@
import numpy as np import numpy as np
import ifcopenshell.api
import ifcopenshell.util.element import ifcopenshell.util.element
import ifcopenshell.util.placement import ifcopenshell.util.placement
import ifcopenshell.api.owner.update_owner_history as update_owner_history
class Usecase: class Usecase:
@@ -47,7 +47,7 @@ class Usecase:
ifcopenshell.util.element.remove_deep(self.file, old) ifcopenshell.util.element.remove_deep(self.file, old)
self.settings["product"].ObjectPlacement = placement self.settings["product"].ObjectPlacement = placement
update_owner_history.Usecase(self.file, {"element": self.settings["product"]}).execute() ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": self.settings["product"]})
for settings in dependent_objects: for settings in dependent_objects:
self.settings = settings self.settings = settings
@@ -1,4 +1,4 @@
import ifcopenshell.api.geometry.remove_representation as remove_representation import ifcopenshell.api
import ifcopenshell.util.element import ifcopenshell.util.element
@@ -53,4 +53,4 @@ class Usecase:
for item in mapped_representations: for item in mapped_representations:
self.unassign_product_representation(item["product"], item["representation"]) self.unassign_product_representation(item["product"], item["representation"])
for representation in just_representations: for representation in just_representations:
remove_representation.Usecase(self.file, {"representation": representation}).execute() ifcopenshell.api.run("owner.remove_representation", self.file, **{"representation": representation})
@@ -1,5 +1,5 @@
import ifcopenshell import ifcopenshell
import ifcopenshell.api.owner.create_owner_history as create_owner_history import ifcopenshell.api
class Usecase: class Usecase:
@@ -12,6 +12,6 @@ class Usecase:
def execute(self): def execute(self):
return self.file.create_entity("IfcGroup", **{ return self.file.create_entity("IfcGroup", **{
"GlobalId": ifcopenshell.guid.new(), "GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": create_owner_history.Usecase(self.file).execute(), "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
"Name": "Unnamed" "Name": "Unnamed"
}) })
@@ -1,6 +1,5 @@
import ifcopenshell import ifcopenshell
import ifcopenshell.api.owner.create_owner_history as create_owner_history import ifcopenshell.api
import ifcopenshell.api.owner.update_owner_history as update_owner_history
class Usecase: class Usecase:
@@ -17,7 +16,7 @@ class Usecase:
if not self.settings["group"].IsGroupedBy: if not self.settings["group"].IsGroupedBy:
return self.file.create_entity("IfcRelAssignsToGroup", **{ return self.file.create_entity("IfcRelAssignsToGroup", **{
"GlobalId": ifcopenshell.guid.new(), "GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": create_owner_history.Usecase(self.file).execute(), "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
"RelatedObjects": [self.settings["product"]], "RelatedObjects": [self.settings["product"]],
"RelatingGroup": self.settings["group"] "RelatingGroup": self.settings["group"]
}) })
@@ -25,4 +24,4 @@ class Usecase:
related_objects = set(rel.RelatedObjects) or set() related_objects = set(rel.RelatedObjects) or set()
related_objects.add(self.settings["product"]) related_objects.add(self.settings["product"])
rel.RelatedObjects = list(related_objects) rel.RelatedObjects = list(related_objects)
update_owner_history.Usecase(self.file, {"element": rel}).execute() ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
@@ -1,5 +1,5 @@
import ifcopenshell import ifcopenshell
import ifcopenshell.api.owner.update_owner_history as update_owner_history import ifcopenshell.api
class Usecase: class Usecase:
@@ -20,6 +20,6 @@ class Usecase:
related_objects.remove(self.settings["product"]) related_objects.remove(self.settings["product"])
if len(related_objects): if len(related_objects):
rel.RelatedObjects = list(related_objects) rel.RelatedObjects = list(related_objects)
update_owner_history.Usecase(self.file, {"element": rel}).execute() ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
else: else:
self.file.remove(rel) self.file.remove(rel)
@@ -1,6 +1,6 @@
import time import time
import ifcopenshell import ifcopenshell
import ifcopenshell.api.owner.create_owner_history as create_owner_history import ifcopenshell.api
class Usecase: class Usecase:
@@ -14,7 +14,9 @@ class Usecase:
self.settings["person"] = ifcopenshell.api.owner.settings.get_person() self.settings["person"] = ifcopenshell.api.owner.settings.get_person()
self.settings["organisation"] = ifcopenshell.api.owner.settings.get_organisation() self.settings["organisation"] = ifcopenshell.api.owner.settings.get_organisation()
if not self.settings["element"].OwnerHistory: if not self.settings["element"].OwnerHistory:
self.settings["element"].OwnerHistory = create_owner_history.Usecase(self.file, self.settings).execute() self.settings["element"].OwnerHistory = ifcopenshell.api.run(
"owner.create_owner_history", self.file, **self.settings
)
return self.settings["element"].OwnerHistory return self.settings["element"].OwnerHistory
if len(self.file.get_inverse(self.settings["element"].OwnerHistory)) > 1: if len(self.file.get_inverse(self.settings["element"].OwnerHistory)) > 1:
old_history = self.settings["element"].OwnerHistory old_history = self.settings["element"].OwnerHistory
@@ -1,5 +1,5 @@
import ifcopenshell import ifcopenshell
import ifcopenshell.api.owner.create_owner_history as create_owner_history import ifcopenshell.api
class Usecase: class Usecase:
@@ -16,7 +16,7 @@ class Usecase:
def execute(self): def execute(self):
element = self.file.create_entity(self.settings["ifc_class"], **{ element = self.file.create_entity(self.settings["ifc_class"], **{
"GlobalId": ifcopenshell.guid.new(), "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 element.Name = self.settings["name"] or None
if self.settings["predefined_type"]: if self.settings["predefined_type"]:
@@ -1,5 +1,4 @@
import ifcopenshell.api.geometry.unassign_representation as unassign_representation import ifcopenshell.api
import ifcopenshell.api.geometry.remove_representation as remove_representation
class Usecase: class Usecase:
@@ -19,9 +18,9 @@ class Usecase:
elif self.settings["product"].is_a("IfcTypeProduct"): elif self.settings["product"].is_a("IfcTypeProduct"):
representations = [rm.MappedRepresentation for rm in self.settings["product"].RepresentationMaps or []] representations = [rm.MappedRepresentation for rm in self.settings["product"].RepresentationMaps or []]
for representation in representations: for representation in representations:
unassign_representation.Usecase( ifcopenshell.api.run("owner.unassign_representation",
self.file, {"product": self.settings["product"], "representation": representation} self.file, **{"product": self.settings["product"], "representation": representation}
).execute() )
remove_representation.Usecase(self.file, {"representation": representation}).execute() ifcopenshell.api.run("owner.remove_representation", self.file, **{"representation": representation})
# TODO: remove object placement and other relationships # TODO: remove object placement and other relationships
self.file.remove(self.settings["product"]) self.file.remove(self.settings["product"])
@@ -1,6 +1,5 @@
import ifcopenshell import ifcopenshell
import ifcopenshell.api.owner.create_owner_history as create_owner_history import ifcopenshell.api
import ifcopenshell.api.owner.update_owner_history as update_owner_history
class Usecase: class Usecase:
@@ -25,7 +24,7 @@ class Usecase:
related_elements.remove(self.settings["product"]) related_elements.remove(self.settings["product"])
if related_elements: if related_elements:
contained_in_structure[0].RelatedElements = related_elements contained_in_structure[0].RelatedElements = related_elements
update_owner_history.Usecase(self.file, {"element": contained_in_structure[0]}).execute() ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": contained_in_structure[0]})
else: else:
self.file.remove(contained_in_structure[0]) self.file.remove(contained_in_structure[0])
@@ -33,13 +32,13 @@ class Usecase:
related_elements = list(contains_elements[0].RelatedElements) related_elements = list(contains_elements[0].RelatedElements)
related_elements.append(self.settings["product"]) related_elements.append(self.settings["product"])
contains_elements[0].RelatedElements = related_elements contains_elements[0].RelatedElements = related_elements
update_owner_history.Usecase(self.file, {"element": contains_elements[0]}).execute() ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": contains_elements[0]})
else: else:
contains_elements = self.file.create_entity( contains_elements = self.file.create_entity(
"IfcRelContainedInSpatialStructure", "IfcRelContainedInSpatialStructure",
**{ **{
"GlobalId": ifcopenshell.guid.new(), "GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": create_owner_history.Usecase(self.file).execute(), "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
"RelatedElements": [self.settings["product"]], "RelatedElements": [self.settings["product"]],
"RelatingStructure": self.settings["relating_structure"], "RelatingStructure": self.settings["relating_structure"],
} }
@@ -1,5 +1,5 @@
import ifcopenshell import ifcopenshell
import ifcopenshell.api.owner.update_owner_history as update_owner_history import ifcopenshell.api
class Usecase: class Usecase:
@@ -17,6 +17,6 @@ class Usecase:
related_elements.remove(self.settings["product"]) related_elements.remove(self.settings["product"])
if related_elements: if related_elements:
contained_in_structure[0].RelatedElements = related_elements contained_in_structure[0].RelatedElements = related_elements
update_owner_history.Usecase(self.file, {"element": contained_in_structure[0]}).execute() ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": contained_in_structure[0]})
else: else:
self.file.remove(contained_in_structure) self.file.remove(contained_in_structure)
@@ -1,5 +1,5 @@
import ifcopenshell import ifcopenshell
import ifcopenshell.api.owner.create_owner_history as create_owner_history import ifcopenshell.api
class Usecase: class Usecase:
@@ -12,7 +12,7 @@ class Usecase:
def execute(self): def execute(self):
return self.file.create_entity("IfcStructuralAnalysisModel", **{ return self.file.create_entity("IfcStructuralAnalysisModel", **{
"GlobalId": ifcopenshell.guid.new(), "GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": create_owner_history.Usecase(self.file).execute(), "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
"Name": "Unnamed", "Name": "Unnamed",
"PredefinedType": "LOADING_3D" "PredefinedType": "LOADING_3D"
}) })
@@ -1,6 +1,5 @@
import ifcopenshell import ifcopenshell
import ifcopenshell.api.owner.create_owner_history as create_owner_history import ifcopenshell.api
import ifcopenshell.api.owner.update_owner_history as update_owner_history
class Usecase: class Usecase:
@@ -17,7 +16,7 @@ class Usecase:
if not self.settings["structural_analysis_model"].IsGroupedBy: if not self.settings["structural_analysis_model"].IsGroupedBy:
return self.file.create_entity("IfcRelAssignsToGroup", **{ return self.file.create_entity("IfcRelAssignsToGroup", **{
"GlobalId": ifcopenshell.guid.new(), "GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": create_owner_history.Usecase(self.file).execute(), "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
"RelatedObjects": [self.settings["product"]], "RelatedObjects": [self.settings["product"]],
"RelatingGroup": self.settings["structural_analysis_model"] "RelatingGroup": self.settings["structural_analysis_model"]
}) })
@@ -25,4 +24,4 @@ class Usecase:
related_objects = set(rel.RelatedObjects) or set() related_objects = set(rel.RelatedObjects) or set()
related_objects.add(self.settings["product"]) related_objects.add(self.settings["product"])
rel.RelatedObjects = list(related_objects) rel.RelatedObjects = list(related_objects)
update_owner_history.Usecase(self.file, {"element": rel}).execute() ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
@@ -1,5 +1,5 @@
import ifcopenshell import ifcopenshell
import ifcopenshell.api.owner.update_owner_history as update_owner_history import ifcopenshell.api
class Usecase: class Usecase:
@@ -20,6 +20,6 @@ class Usecase:
related_objects.remove(self.settings["product"]) related_objects.remove(self.settings["product"])
if len(related_objects): if len(related_objects):
rel.RelatedObjects = list(related_objects) rel.RelatedObjects = list(related_objects)
update_owner_history.Usecase(self.file, {"element": rel}).execute() ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
else: else:
self.file.remove(rel) self.file.remove(rel)
@@ -1,6 +1,5 @@
import ifcopenshell import ifcopenshell
import ifcopenshell.api.owner.create_owner_history as create_owner_history import ifcopenshell.api
import ifcopenshell.api.owner.update_owner_history as update_owner_history
class Usecase: class Usecase:
@@ -34,7 +33,7 @@ class Usecase:
related_objects.remove(self.settings["related_object"]) related_objects.remove(self.settings["related_object"])
if related_objects: if related_objects:
is_typed_by[0].RelatedObjects = related_objects is_typed_by[0].RelatedObjects = related_objects
update_owner_history.Usecase(self.file, {"element": is_typed_by[0]}).execute() ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": is_typed_by[0]})
else: else:
self.file.remove(is_typed_by[0]) self.file.remove(is_typed_by[0])
@@ -42,13 +41,13 @@ class Usecase:
related_objects = list(types[0].RelatedObjects) related_objects = list(types[0].RelatedObjects)
related_objects.append(self.settings["related_object"]) related_objects.append(self.settings["related_object"])
types[0].RelatedObjects = related_objects types[0].RelatedObjects = related_objects
update_owner_history.Usecase(self.file, {"element": types[0]}).execute() ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": types[0]})
else: else:
types = self.file.create_entity( types = self.file.create_entity(
"IfcRelDefinesByType", "IfcRelDefinesByType",
**{ **{
"GlobalId": ifcopenshell.guid.new(), "GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": create_owner_history.Usecase(self.file).execute(), "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
"RelatedObjects": [self.settings["related_object"]], "RelatedObjects": [self.settings["related_object"]],
"RelatingType": self.settings["relating_type"], "RelatingType": self.settings["relating_type"],
} }
@@ -1,5 +1,5 @@
import ifcopenshell import ifcopenshell
import ifcopenshell.api.owner.update_owner_history as update_owner_history import ifcopenshell.api
class Usecase: class Usecase:
@@ -28,6 +28,6 @@ class Usecase:
related_objects.remove(self.settings["related_object"]) related_objects.remove(self.settings["related_object"])
if related_objects: if related_objects:
is_typed_by.RelatedObjects = related_objects is_typed_by.RelatedObjects = related_objects
update_owner_history.Usecase(self.file, {"element": is_typed_by}).execute() ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": is_typed_by})
else: else:
self.file.remove(is_typed_by) self.file.remove(is_typed_by)
@@ -1,5 +1,5 @@
import ifcopenshell import ifcopenshell
import ifcopenshell.api.owner.create_owner_history as create_owner_history import ifcopenshell.api
class Usecase: class Usecase:
@@ -12,7 +12,7 @@ class Usecase:
def execute(self): def execute(self):
self.file.create_entity("IfcRelVoidsElement", **{ self.file.create_entity("IfcRelVoidsElement", **{
"GlobalId": ifcopenshell.guid.new(), "GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": create_owner_history.Usecase(self.file).execute(), "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
"RelatingBuildingElement": self.settings["element"], "RelatingBuildingElement": self.settings["element"],
"RelatedOpeningElement": self.settings["opening"] "RelatedOpeningElement": self.settings["opening"]
}) })