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