diff --git a/src/bonsai/bonsai/bim/export_ifc.py b/src/bonsai/bonsai/bim/export_ifc.py index d507481141..6134786124 100644 --- a/src/bonsai/bonsai/bim/export_ifc.py +++ b/src/bonsai/bonsai/bim/export_ifc.py @@ -25,6 +25,7 @@ import zipfile import tempfile import ifcopenshell import ifcopenshell.api +import ifcopenshell.util.element import ifcopenshell.util.placement import ifcopenshell.util.unit import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/import_ifc.py b/src/bonsai/bonsai/bim/import_ifc.py index 1765b1ca24..539ec89736 100644 --- a/src/bonsai/bonsai/bim/import_ifc.py +++ b/src/bonsai/bonsai/bim/import_ifc.py @@ -28,6 +28,7 @@ import numpy as np import numpy.typing as npt import multiprocessing import ifcopenshell +import ifcopenshell.api.pset import ifcopenshell.geom import ifcopenshell.ifcopenshell_wrapper as W import ifcopenshell.util.unit @@ -1237,8 +1238,7 @@ class IfcImporter: if not pset: return if "Aggregate_Index" not in pset.keys(): - ifcopenshell.api.run( - "pset.edit_pset", + ifcopenshell.api.pset.edit_pset( self.file, pset=self.file.by_id(pset["id"]), properties={"Aggregate_Index": aggregate_index, "Name": name}, diff --git a/src/bonsai/bonsai/bim/module/aggregate/operator.py b/src/bonsai/bonsai/bim/module/aggregate/operator.py index e35b982d65..5fa6885335 100644 --- a/src/bonsai/bonsai/bim/module/aggregate/operator.py +++ b/src/bonsai/bonsai/bim/module/aggregate/operator.py @@ -21,6 +21,7 @@ import ifcopenshell import ifcopenshell.api import ifcopenshell.api.group import ifcopenshell.api.pset +import ifcopenshell.api.root import ifcopenshell.util.element import bonsai.tool as tool import bonsai.core.aggregate as core diff --git a/src/bonsai/bonsai/bim/module/drawing/helper.py b/src/bonsai/bonsai/bim/module/drawing/helper.py index bfd943afa6..3f250373b5 100644 --- a/src/bonsai/bonsai/bim/module/drawing/helper.py +++ b/src/bonsai/bonsai/bim/module/drawing/helper.py @@ -18,6 +18,7 @@ import bpy import math +import ifcopenshell.util.element import mathutils.geometry import ifcopenshell import ifcopenshell.util.unit diff --git a/src/bonsai/bonsai/bim/module/geometry/operator.py b/src/bonsai/bonsai/bim/module/geometry/operator.py index 248a226244..a27849da31 100644 --- a/src/bonsai/bonsai/bim/module/geometry/operator.py +++ b/src/bonsai/bonsai/bim/module/geometry/operator.py @@ -42,6 +42,7 @@ import bonsai.core.geometry import bonsai.core.geometry as core import bonsai.core.aggregate import bonsai.core.nest +import bonsai.core.spatial import bonsai.core.style import bonsai.core.root import bonsai.core.drawing diff --git a/src/bonsai/bonsai/tool/drawing.py b/src/bonsai/bonsai/tool/drawing.py index 00fd6c9505..10ef99ca22 100644 --- a/src/bonsai/bonsai/tool/drawing.py +++ b/src/bonsai/bonsai/tool/drawing.py @@ -38,12 +38,15 @@ import bonsai.core.geometry import bonsai.core.type import bonsai.tool as tool import ifcopenshell.api +import ifcopenshell.api.geometry import ifcopenshell.api.context import ifcopenshell.api.drawing import ifcopenshell.api.document import ifcopenshell.api.pset import ifcopenshell.api.root import ifcopenshell.geom +import ifcopenshell.util.placement +import ifcopenshell.util.unit import ifcopenshell.util.representation import ifcopenshell.util.element import ifcopenshell.util.selector diff --git a/src/ifctester/test/test_facet.py b/src/ifctester/test/test_facet.py index 167201979b..3d7518d99f 100644 --- a/src/ifctester/test/test_facet.py +++ b/src/ifctester/test/test_facet.py @@ -25,6 +25,7 @@ import ifcopenshell.api.classification import ifcopenshell.api.group import ifcopenshell.api.material import ifcopenshell.api.nest +import ifcopenshell.api.owner.settings import ifcopenshell.api.pset import ifcopenshell.api.root import ifcopenshell.api.spatial diff --git a/src/pyodide/demo-app/context.py b/src/pyodide/demo-app/context.py index 109db84e0f..8cece9ef68 100644 --- a/src/pyodide/demo-app/context.py +++ b/src/pyodide/demo-app/context.py @@ -1,7 +1,15 @@ import ifcopenshell +import ifcopenshell.api.aggregate +import ifcopenshell.api.context import ifcopenshell.api.feature +import ifcopenshell.api.geometry +import ifcopenshell.api.root +import ifcopenshell.api.spatial +import ifcopenshell.api.type +import ifcopenshell.api.unit import ifcopenshell.geom import ifcopenshell.api +import ifcopenshell.util.representation import ifcopenshell.util.unit import numpy as np @@ -33,9 +41,8 @@ class Context: if body: self.body = body[0] else: - context = ifcopenshell.api.run("context.add_context", self.model, context_type="Model") - self.body = ifcopenshell.api.run( - "context.add_context", + context = ifcopenshell.api.context.add_context(self.model, context_type="Model") + self.body = ifcopenshell.api.context.add_context( self.model, context_type="Model", context_identifier="Body", @@ -48,9 +55,8 @@ class Context: if body: self.axis = axis[0] else: - context = ifcopenshell.api.run("context.add_context", self.model, context_type="Model") - self.axis = ifcopenshell.api.run( - "context.add_context", + context = ifcopenshell.api.context.add_context(self.model, context_type="Model") + self.axis = ifcopenshell.api.context.add_context( self.model, context_type="Model", context_identifier="Axis", @@ -63,23 +69,21 @@ class Context: # Create a blank model self.model = ifcopenshell.file() # All projects must have one IFC Project element - project = ifcopenshell.api.run("root.create_entity", self.model, ifc_class="IfcProject", name="My Project") + project = ifcopenshell.api.root.create_entity(self.model, ifc_class="IfcProject", name="My Project") # Geometry is optional in IFC, but because we want to use geometry in this example, let's define units # Assigning without arguments defaults to metric units - ifcopenshell.api.run("unit.assign_unit", self.model) + ifcopenshell.api.unit.assign_unit(self.model) # Let's create a modeling geometry context, so we can store 3D geometry (note: IFC supports 2D too!) - context = ifcopenshell.api.run("context.add_context", self.model, context_type="Model") + context = ifcopenshell.api.context.add_context(self.model, context_type="Model") # In particular, in this example we want to store the 3D "body" geometry of objects, i.e. the body shape - self.body = ifcopenshell.api.run( - "context.add_context", + self.body = ifcopenshell.api.context.add_context( self.model, context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=context, ) - self.axis = ifcopenshell.api.run( - "context.add_context", + self.axis = ifcopenshell.api.context.add_context( self.model, context_type="Model", context_identifier="Axis", @@ -87,30 +91,26 @@ class Context: parent=context, ) # Create a site, building, and storey. Many hierarchies are possible. - site = ifcopenshell.api.run("root.create_entity", self.model, ifc_class="IfcSite", name="My Site") - building = ifcopenshell.api.run("root.create_entity", self.model, ifc_class="IfcBuilding", name="Building A") - self.storey = ifcopenshell.api.run( - "root.create_entity", + site = ifcopenshell.api.root.create_entity(self.model, ifc_class="IfcSite", name="My Site") + building = ifcopenshell.api.root.create_entity(self.model, ifc_class="IfcBuilding", name="Building A") + self.storey = ifcopenshell.api.root.create_entity( self.model, ifc_class="IfcBuildingStorey", name="Ground Floor", ) # Since the site is our top level location, assign it to the project # Then place our building on the site, and our storey in the building - ifcopenshell.api.run( - "aggregate.assign_object", + ifcopenshell.api.aggregate.assign_object( self.model, relating_object=project, products=[site], ) - ifcopenshell.api.run( - "aggregate.assign_object", + ifcopenshell.api.aggregate.assign_object( self.model, relating_object=site, products=[building], ) - ifcopenshell.api.run( - "aggregate.assign_object", + ifcopenshell.api.aggregate.assign_object( self.model, relating_object=building, products=[self.storey], @@ -120,30 +120,26 @@ class Context: p1 = np.array([p1[0], p1[1]]) p2 = np.array([p2[0], p2[1]]) - wall = ifcopenshell.api.run("root.create_entity", self.model, ifc_class="IfcWall") + wall = ifcopenshell.api.root.create_entity(self.model, ifc_class="IfcWall") length = float(np.linalg.norm(p2 - p1)) - representation = ifcopenshell.api.run( - "geometry.add_wall_representation", + representation = ifcopenshell.api.geometry.add_wall_representation( self.model, context=self.body, length=length, height=height, thickness=thickness, ) - ifcopenshell.api.run( - "geometry.assign_representation", + ifcopenshell.api.geometry.assign_representation( self.model, product=wall, representation=representation, ) - representation = ifcopenshell.api.run( - "geometry.add_axis_representation", + representation = ifcopenshell.api.geometry.add_axis_representation( self.model, context=self.axis, axis=[(0.0, 0.0), (length, 0.0)], ) - ifcopenshell.api.run( - "geometry.assign_representation", + ifcopenshell.api.geometry.assign_representation( self.model, product=wall, representation=representation, @@ -158,16 +154,14 @@ class Context: [0, 0, 0, 1], ] ) - ifcopenshell.api.run("geometry.edit_object_placement", self.model, product=wall, matrix=matrix) - ifcopenshell.api.run( - "spatial.assign_container", + ifcopenshell.api.geometry.edit_object_placement(self.model, product=wall, matrix=matrix) + ifcopenshell.api.spatial.assign_container( self.model, relating_structure=container, products=[wall], ) if wall_type: - ifcopenshell.api.run( - "type.assign_type", + ifcopenshell.api.type.assign_type( self.model, related_object=wall, relating_type=wall_type, @@ -196,20 +190,19 @@ class Context: body = ifcopenshell.util.representation.get_context(self.model, "Model", "Body", "MODEL_VIEW") representation_data = props.to_dict(si_conversion=si_conversion) representation_data["context"] = body - door_representation = ifcopenshell.api.run( - f"geometry.add_{ty}_representation", self.model, **representation_data - ) - door = ifcopenshell.api.run("root.create_entity", self.model, ifc_class=f"ifc{ty}") + if ty == "door": + door_representation = ifcopenshell.api.geometry.add_door_representation(self.model, **representation_data) + else: + door_representation = ifcopenshell.api.geometry.add_window_representation(self.model, **representation_data) + door = ifcopenshell.api.root.create_entity(self.model, ifc_class=f"ifc{ty}") door.OverallWidth = props.overall_width / si_conversion door.OverallHeight = props.overall_height / si_conversion - ifcopenshell.api.run( - "geometry.assign_representation", + ifcopenshell.api.geometry.assign_representation( self.model, product=door, representation=door_representation, ) - ifcopenshell.api.run( - "spatial.assign_container", + ifcopenshell.api.spatial.assign_container( self.model, relating_structure=self.storey, products=[door], @@ -238,8 +231,7 @@ class Context: v_dot_v = np.dot(v, v) t = AP_dot_v / v_dot_v * np.linalg.norm(v) / si_conversion - opening = ifcopenshell.api.run( - "root.create_entity", + opening = ifcopenshell.api.root.create_entity( self.model, ifc_class="IfcOpeningElement", predefined_type="OPENING",