@@ -51,21 +51,11 @@ def add_instance_flooring_covering_from_cursor(
5151 if isinstance (space_polygon , str ):
5252 return
5353
54- bm = spatial .get_bmesh_from_polygon (space_polygon , h = 0 , polygon_is_si = True )
55- name = "Covering"
56- mesh = spatial .get_named_mesh_from_bmesh (name = name , bmesh = bm )
57-
58- obj = spatial .get_named_obj_from_mesh (name , mesh )
59-
54+ obj = spatial .create_object ("Covering" )
6055 spatial .set_obj_origin_to_cursor_position_and_zero_elevation (obj )
6156 spatial .translate_obj_to_z_location (obj , z )
62- points = spatial .get_2d_vertices_from_obj (obj )
63- points = spatial .get_scaled_2d_vertices (points )
6457 spatial .assign_type_to_obj (obj )
65-
66- spatial .assign_swept_area_outer_curve_from_2d_vertices (obj , vertices = points )
67- body = spatial .get_body_representation (obj )
68- spatial .regen_obj_representation (obj , body )
58+ spatial .set_covering_representation_from_polygon (obj , space_polygon , polygon_is_si = True )
6959
7060
7161def add_instance_ceiling_covering_from_cursor (
@@ -95,21 +85,11 @@ def add_instance_ceiling_covering_from_cursor(
9585 if isinstance (space_polygon , str ):
9686 return
9787
98- bm = spatial .get_bmesh_from_polygon (space_polygon , h = 0 , polygon_is_si = True )
99- name = "Covering"
100- mesh = spatial .get_named_mesh_from_bmesh (name = name , bmesh = bm )
101-
102- obj = spatial .get_named_obj_from_mesh (name , mesh )
103-
88+ obj = spatial .create_object ("Covering" )
10489 spatial .set_obj_origin_to_cursor_position_and_zero_elevation (obj )
10590 spatial .translate_obj_to_z_location (obj , z + ceiling_height )
106- points = spatial .get_2d_vertices_from_obj (obj )
107- points = spatial .get_scaled_2d_vertices (points )
10891 spatial .assign_type_to_obj (obj )
109-
110- spatial .assign_swept_area_outer_curve_from_2d_vertices (obj , vertices = points )
111- body = spatial .get_body_representation (obj )
112- spatial .regen_obj_representation (obj , body )
92+ spatial .set_covering_representation_from_polygon (obj , space_polygon , polygon_is_si = True )
11393
11494
11595def regen_selected_covering_object (root : type [tool .Root ], spatial : type [tool .Spatial ]) -> None :
@@ -127,19 +107,7 @@ def regen_selected_covering_object(root: type[tool.Root], spatial: type[tool.Spa
127107 if isinstance (space_polygon , str ):
128108 return
129109
130- bm = spatial .get_bmesh_from_polygon (space_polygon , h = 0 , polygon_is_si = True )
131-
132- name = "Aux"
133- mesh = spatial .get_named_mesh_from_bmesh (name = name , bmesh = bm )
134- mesh = spatial .get_transformed_mesh_from_local_to_global (mesh )
135- obj = spatial .get_named_obj_from_mesh (name , mesh )
136-
137- points = spatial .get_2d_vertices_from_obj (obj )
138- points = spatial .get_scaled_2d_vertices (points )
139-
140- spatial .assign_swept_area_outer_curve_from_2d_vertices (active_obj , vertices = points )
141- body = spatial .get_body_representation (active_obj )
142- spatial .regen_obj_representation (active_obj , body )
110+ spatial .set_covering_representation_from_polygon (active_obj , space_polygon , polygon_is_si = True )
143111
144112
145113# TODO CHECK IF IT IS POSSIBLE TO CREATE ONLY ONE CORE FUNCTION FOR _FROM_WALLS
@@ -151,22 +119,13 @@ def add_instance_flooring_coverings_from_walls(root: type[tool.Root], spatial: t
151119 union = spatial .get_union_shape_from_selected_objects ()
152120 for i , linear_ring in enumerate (union .interiors ):
153121 poly = spatial .get_buffered_poly_from_linear_ring (linear_ring )
154- bm = spatial .get_bmesh_from_polygon (poly , h = 0 , polygon_is_si = False )
155122
156123 name = "Covering" + str (i )
157- obj = spatial .get_named_obj_from_bmesh (name , bmesh = bm )
158-
159- spatial .set_obj_origin_to_bboxcenter (obj )
124+ obj = spatial .create_object (name )
125+ spatial .set_obj_origin_to_polygon_center (obj , poly , polygon_is_si = False )
160126 spatial .translate_obj_to_z_location (obj , z )
161-
162- points = spatial .get_2d_vertices_from_obj (obj )
163- points = spatial .get_scaled_2d_vertices (points )
164-
165127 spatial .assign_type_to_obj (obj )
166-
167- spatial .assign_swept_area_outer_curve_from_2d_vertices (obj , vertices = points )
168- body = spatial .get_body_representation (obj )
169- spatial .regen_obj_representation (obj , body )
128+ spatial .set_covering_representation_from_polygon (obj , poly , polygon_is_si = False )
170129
171130
172131def add_instance_ceiling_coverings_from_walls (
@@ -179,22 +138,13 @@ def add_instance_ceiling_coverings_from_walls(
179138 union = spatial .get_union_shape_from_selected_objects ()
180139 for i , linear_ring in enumerate (union .interiors ):
181140 poly = spatial .get_buffered_poly_from_linear_ring (linear_ring )
182- bm = spatial .get_bmesh_from_polygon (poly , h = 0 , polygon_is_si = False )
183141
184142 name = "Covering" + str (i )
185- obj = spatial .get_named_obj_from_bmesh (name , bmesh = bm )
186-
187- spatial .set_obj_origin_to_bboxcenter (obj )
143+ obj = spatial .create_object (name )
144+ spatial .set_obj_origin_to_polygon_center (obj , poly , polygon_is_si = False )
188145 spatial .translate_obj_to_z_location (obj , z )
189-
190- points = spatial .get_2d_vertices_from_obj (obj )
191- points = spatial .get_scaled_2d_vertices (points )
192-
193146 spatial .assign_type_to_obj (obj )
194-
195- spatial .assign_swept_area_outer_curve_from_2d_vertices (obj , vertices = points )
196- body = spatial .get_body_representation (obj )
197- spatial .regen_obj_representation (obj , body )
147+ spatial .set_covering_representation_from_polygon (obj , poly , polygon_is_si = False )
198148
199149
200150class NoDefaultContainer (Exception ):
0 commit comments