small refactor

This commit is contained in:
Andrej730
2024-05-24 16:11:27 +05:00
parent df15a37127
commit ac8040008a
@@ -130,7 +130,6 @@ class FilledOpeningGenerator:
existing_opening_occurrence = self.get_existing_opening_occurrence_if_any(filling) existing_opening_occurrence = self.get_existing_opening_occurrence_if_any(filling)
if existing_opening_occurrence:
opening = ifcopenshell.api.run( opening = ifcopenshell.api.run(
"root.create_entity", "root.create_entity",
tool.Ifc.get(), tool.Ifc.get(),
@@ -139,31 +138,23 @@ class FilledOpeningGenerator:
name="Opening", name="Opening",
) )
ifcopenshell.api.run( ifcopenshell.api.run(
"geometry.edit_object_placement", tool.Ifc.get(), product=opening, matrix=filling_obj.matrix_world "geometry.edit_object_placement",
tool.Ifc.get(),
product=opening,
matrix=np.array(filling_obj.matrix_world),
is_si=True,
) )
if existing_opening_occurrence:
representation = ifcopenshell.util.representation.get_representation( representation = ifcopenshell.util.representation.get_representation(
existing_opening_occurrence, "Model", "Body", "MODEL_VIEW" existing_opening_occurrence, "Model", "Body", "MODEL_VIEW"
) )
representation = ifcopenshell.util.representation.resolve_representation(representation) representation = ifcopenshell.util.representation.resolve_representation(representation)
mapped_representation = ifcopenshell.api.run(
"geometry.map_representation", tool.Ifc.get(), representation=representation
)
ifcopenshell.api.run(
"geometry.assign_representation", tool.Ifc.get(), product=opening, representation=mapped_representation
)
else: else:
representation = self.generate_opening_from_filling( representation = self.generate_opening_from_filling(
filling, filling_obj, opening_thickness_si=opening_thickness_si filling, filling_obj, opening_thickness_si=opening_thickness_si
) )
opening = ifcopenshell.api.run(
"root.create_entity", tool.Ifc.get(), ifc_class="IfcOpeningElement", predefined_type="OPENING"
)
matrix = np.array(filling_obj.matrix_world)
ifcopenshell.api.run(
"geometry.edit_object_placement", tool.Ifc.get(), product=opening, matrix=matrix, is_si=True
)
mapped_representation = ifcopenshell.api.run( mapped_representation = ifcopenshell.api.run(
"geometry.map_representation", tool.Ifc.get(), representation=representation "geometry.map_representation", tool.Ifc.get(), representation=representation
) )