@@ -710,7 +710,6 @@ def create_motorized_valve(
710710 add_shape_representation_to_ports : bool = False ,
711711) -> ifcopenshell .entity_instance :
712712
713- # Create Element
714713 if element is None :
715714 element = ifcopenshell .api .root .create_entity (
716715 file = ifc4_file ,
@@ -719,7 +718,6 @@ def create_motorized_valve(
719718 predefined_type = "MOTORIZED" ,
720719 )
721720
722- # Assign spatial container
723721 if isinstance (spatial_element , ifcopenshell .entity_instance ):
724722 ifcopenshell .api .spatial .assign_container (
725723 file = ifc4_file ,
@@ -731,64 +729,74 @@ def create_motorized_valve(
731729 place_object_relative_to_parent = True ,
732730 )
733731
734- # Assign System
735732 if isinstance (distribution_system , ifcopenshell .entity_instance ):
736733 ifcopenshell .api .system .assign_system (
737734 file = ifc4_file ,
738735 products = [element ],
739736 system = distribution_system ,
740737 )
741738
742- # Create Constituted Solid Geometry
743- operands = [
744- bim2fem .ifcplus .api .geometry .add_block ( # Block
745- ifc4_file = ifc4_file ,
746- length = 2 * outer_diameter ,
747- width = 2 / 5 * outer_diameter ,
748- height = 2 / 5 * outer_diameter ,
749- repositioned_origin = (0.0 , 0.0 , outer_diameter ),
750- repositioned_z_axis = (0.0 , 0.0 , 1.0 ),
751- repositioned_x_axis = (1.0 , 0.0 , 0.0 ),
752- ),
753- bim2fem .ifcplus .api .geometry .add_cylindrical_extruded_area_solid ( # Cylinder
754- ifc4_file = ifc4_file ,
755- radius = outer_diameter / 2.0 ,
756- extrusion_depth = 2 / 5 * outer_diameter ,
757- repositioned_origin = (1.5 * outer_diameter , 0.0 , outer_diameter / 2.0 ),
758- repositioned_z_axis = (0.0 , 1.0 , 0.0 ),
759- repositioned_x_axis = (1.0 , 0.0 , 1.0 ),
760- ),
761- bim2fem .ifcplus .api .geometry .add_cylindrical_extruded_area_solid ( # Cylinder
762- ifc4_file = ifc4_file ,
763- radius = outer_diameter / 2.0 - thickness ,
764- extrusion_depth = 2 / 5 * outer_diameter ,
765- repositioned_origin = (1.5 * outer_diameter , 0.0 , outer_diameter / 2.0 ),
766- repositioned_z_axis = (0.0 , 1.0 , 0.0 ),
767- repositioned_x_axis = (1.0 , 0.0 , 1.0 ),
768- ),
769- ]
739+ block = bim2fem .ifcplus .api .geometry .add_block (
740+ ifc4_file = ifc4_file ,
741+ length = 2 * outer_diameter ,
742+ width = 2 / 5 * outer_diameter ,
743+ height = 2 / 5 * outer_diameter ,
744+ repositioned_origin = (0.0 , 0.0 , outer_diameter ),
745+ repositioned_z_axis = (0.0 , 0.0 , 1.0 ),
746+ repositioned_x_axis = (1.0 , 0.0 , 0.0 ),
747+ )
770748
771- # Add and Assign Representation
772- representation_item = bim2fem .ifcplus .api .geometry .add_csg_solid (
773- operands = operands ,
774- boolean_operators = ["UNION" , "DIFFERENCE" ],
749+ cylinder_1 = bim2fem .ifcplus .api .geometry .add_cylindrical_extruded_area_solid (
750+ ifc4_file = ifc4_file ,
751+ radius = outer_diameter / 2.0 ,
752+ extrusion_depth = 2 / 5 * outer_diameter ,
753+ repositioned_origin = (1.5 * outer_diameter , 0.0 , outer_diameter / 2.0 ),
754+ repositioned_z_axis = (0.0 , 1.0 , 0.0 ),
755+ repositioned_x_axis = (1.0 , 0.0 , 1.0 ),
756+ )
757+
758+ cylinder_2 = bim2fem .ifcplus .api .geometry .add_cylindrical_extruded_area_solid (
759+ ifc4_file = ifc4_file ,
760+ radius = outer_diameter / 2.0 - thickness ,
761+ extrusion_depth = 2 / 5 * outer_diameter ,
762+ repositioned_origin = (1.5 * outer_diameter , 0.0 , outer_diameter / 2.0 ),
763+ repositioned_z_axis = (0.0 , 1.0 , 0.0 ),
764+ repositioned_x_axis = (1.0 , 0.0 , 1.0 ),
775765 )
766+
767+ boolean_result_1 = ifcopenshell .api .geometry .add_boolean (
768+ file = ifc4_file ,
769+ first_item = block ,
770+ second_items = [cylinder_1 ],
771+ operator = "UNION" ,
772+ )[- 1 ]
773+
774+ boolean_result_2 = ifcopenshell .api .geometry .add_boolean (
775+ file = ifc4_file ,
776+ first_item = boolean_result_1 ,
777+ second_items = [cylinder_2 ],
778+ operator = "DIFFERENCE" ,
779+ )[- 1 ]
780+
781+ csg_solid = bim2fem .ifcplus .api .geometry .add_csg_solid (
782+ boolean_result_or_primitive = boolean_result_2 ,
783+ )
784+
785+ representation_type = ifcopenshell .util .representation .guess_type (items = [csg_solid ])
786+
776787 shape_model = bim2fem .ifcplus .api .geometry .add_shape_model (
777788 ifc4_file = ifc4_file ,
778789 shape_model_class = "IfcShapeRepresentation" ,
779790 representation_identifier = "Body" ,
780- representation_type = "CSG" ,
781- context_type = "Model" ,
782- target_view = "MODEL_VIEW" ,
783- items = [representation_item ],
791+ representation_type = cast (str , representation_type ),
792+ items = [csg_solid ],
784793 )
785794 ifcopenshell .api .geometry .assign_representation (
786795 file = ifc4_file ,
787796 product = element ,
788797 representation = shape_model ,
789798 )
790799
791- # Edit Element Placement
792800 bim2fem .ifcplus .api .placement .edit_object_placement (
793801 product = element ,
794802 repositioned_origin = (0.0 , 0.0 , 0.0 ),
@@ -797,7 +805,6 @@ def create_motorized_valve(
797805 place_object_relative_to_parent = place_object_relative_to_parent ,
798806 )
799807
800- # Add and Assign Type
801808 element_type = bim2fem .ifcplus .api .element_type .add_element_type (
802809 ifc4_file = ifc4_file ,
803810 ifc_class = ifcopenshell .util .type .get_applicable_types (ifc_class = element .is_a ())[
@@ -812,7 +819,6 @@ def create_motorized_valve(
812819 relating_type = element_type ,
813820 )
814821
815- # Port 1
816822 port1_origin_in_object_coordinates = (
817823 1.5 * outer_diameter ,
818824 0.0 ,
@@ -838,7 +844,6 @@ def create_motorized_valve(
838844 place_object_relative_to_parent = True ,
839845 )
840846
841- # Port 2
842847 port2_origin_in_object_coordinates = (
843848 1.5 * outer_diameter ,
844849 2 / 5 * outer_diameter ,
0 commit comments