Skip to content

Commit

Permalink
fix tapered beam test
Browse files Browse the repository at this point in the history
  • Loading branch information
Krande committed Dec 16, 2024
1 parent 65a7de1 commit 4e4d1a7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/ada/api/spatial/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ def ifc_store(self) -> IfcStore:
from ada.cadit.ifc.store import IfcStore
from ada.cadit.ifc.utils import assembly_to_ifc_file

self._ifc_file = assembly_to_ifc_file(self)
f = assembly_to_ifc_file(self)

self._ifc_file = f
self._ifc_store = IfcStore(assembly=self)

return self._ifc_store
Expand Down
6 changes: 0 additions & 6 deletions src/ada/cadit/ifc/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,6 @@ def sync(
mod_str = f"Modified {num_mod} objects"
del_str = f"Deleted {num_del} objects"

unit_type = get_unit_type(self.f)

if unit_type != self.assembly.units:
# todo: fix unit conversion
self.f = convert_file_length_units(self.f, self.assembly.units)

print(f"Sync Complete. {add_str}. {mod_str}. {del_str}")
self.callback = None

Expand Down
4 changes: 3 additions & 1 deletion src/ada/cadit/ifc/units_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def is_attr_type(
def iter_element_and_attributes_per_type(
ifc_file: ifcopenshell.file, attr_type_name: str
) -> Iterable[tuple[ifcopenshell.entity_instance, ifcopenshell.ifcopenshell_wrapper.attribute, Any, str]]:
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema)
schema_map = {"IFC4X3": "IFC4X3_ADD2"}
schema_name = schema_map.get(ifc_file.schema, ifc_file.schema)
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema_name)

for element in ifc_file:
entity = schema.declaration_by_name(element.is_a())
Expand Down
2 changes: 1 addition & 1 deletion src/ada/cadit/ifc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ def create_local_placement(f: ifcopenshell.file, origin=ifco.O, loc_z=ifco.Z, lo

def assembly_to_ifc_file(a: "Assembly"):
schema = a.metadata["schema"]
# f = ifcopenshell.file(a.name + ".ifc", schema_version=)
f = ifcopenshell.api.run("project.create_file", version=schema)
project = ifcopenshell.api.run("root.create_entity", f, ifc_class="IfcProject", name=a.metadata["project"])
f.add(project)

ifcopenshell.api.run("unit.assign_unit", f, **{"length": {"is_metric": True, "raw": "METERS"}})
# 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", f, context_type="Model")
Expand Down
7 changes: 3 additions & 4 deletions tests/core/api/beams/test_beam_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ def test_tapered_profile():
tap = bm.taper
assert sec.r == 0.3
assert tap.r == 0.2
# a = Assembly() / (Part("Test") / bm)
# a.to_ifc(test_dir / "tapered.ifc")


def test_cone_beam(tmp_path):
Expand All @@ -87,6 +85,7 @@ def test_cone_beam(tmp_path):
poly_e_i = CurvePoly2d(e_i, (0, 0, 0), (0, 0, 1), (1, 0, 0))
section_e = Section("MyEndCrossSection", "poly", outer_poly=poly_e_o, inner_poly=poly_e_i, units="mm")

bm = BeamTapered("MyCone", (2, 2, 2), (4, 4, 4), sec=section_s, tap=section_e, units="mm")
a = Assembly("Level1", project="Project0", units="mm") / (Part("Level2") / bm)
bm = BeamTapered("MyCone", (2, 2, 2), (4, 4, 4), sec=section_s, tap=section_e)
a = Assembly("Level1", project="Project0") / (Part("Level2") / bm)

_ = a.to_ifc(tmp_path / "cone_ex.ifc", file_obj_only=False)

0 comments on commit 4e4d1a7

Please sign in to comment.