@@ -61,7 +61,6 @@ def _execute(self, context):
6161 "y" : 0.0 ,
6262 "z" : 0.0 ,
6363 "use_local_space" : True ,
64- "sync_children" : False ,
6564 "method" : "OFFSET" ,
6665 }
6766
@@ -80,28 +79,27 @@ def _execute(self, context):
8079 pset = pset ,
8180 properties = {"Parent" : element .GlobalId , "Data" : ifc_file .create_entity ("IfcText" , json .dumps (data ))},
8281 )
83- return {"FINISHED" }
8482
8583
86- class DisableEditingArray (bpy .types .Operator , tool . Ifc . Operator ):
84+ class DisableEditingArray (bpy .types .Operator ):
8785 bl_idname = "bim.disable_editing_array"
8886 bl_label = "Disable Editing Array"
8987 bl_options = {"REGISTER" , "UNDO" }
9088
91- def _execute (self , context ):
89+ def execute (self , context ):
9290 obj = context .active_object
9391 assert obj
9492 tool .Model .get_array_props (obj ).is_editing = - 1
9593 return {"FINISHED" }
9694
9795
98- class EnableEditingArray (bpy .types .Operator , tool . Ifc . Operator ):
96+ class EnableEditingArray (bpy .types .Operator ):
9997 bl_idname = "bim.enable_editing_array"
10098 bl_label = "Enable Editing Array"
10199 bl_options = {"REGISTER" , "UNDO" }
102100 item : bpy .props .IntProperty ()
103101
104- def _execute (self , context ):
102+ def execute (self , context ):
105103 obj = context .active_object
106104 assert obj
107105 element = tool .Ifc .get_entity (obj )
@@ -122,11 +120,9 @@ def _execute(self, context):
122120 props .y = data ["y" ] * si_conversion
123121 props .z = data ["z" ] * si_conversion
124122 props .use_local_space = data .get ("use_local_space" , False )
125- props .sync_children = data .get ("sync_children" , False )
126123 props .method = data .get ("method" , "OFFSET" )
127124
128125 props .is_editing = self .item
129-
130126 return {"FINISHED" }
131127
132128
@@ -151,31 +147,25 @@ def _execute(self, context):
151147 "y" : props .y / si_conversion ,
152148 "z" : props .z / si_conversion ,
153149 "use_local_space" : props .use_local_space ,
154- "sync_children" : props .sync_children ,
155150 "method" : props .method ,
156151 }
157152
158153 props .is_editing = - 1
159154
160155 try :
161- parent = tool .Ifc .get_object (tool .Ifc .get ().by_guid (pset ["Parent" ]))
156+ parent_element = tool .Ifc .get ().by_guid (pset ["Parent" ])
157+ parent = tool .Ifc .get_object (parent_element )
162158 except :
163159 return {"FINISHED" }
164160
161+ tool .Blender .Modifier .Array .remove_constraints (parent_element )
165162 tool .Model .regenerate_array (parent , data )
166-
167- pset = tool .Ifc .get ().by_id (pset ["id" ])
168- data = tool .Ifc .get ().createIfcText (json .dumps (data ))
169- ifcopenshell .api .pset .edit_pset (tool .Ifc .get (), pset = pset , properties = {"Data" : data })
170-
171163 tool .Blender .Modifier .Array .set_children_lock_state (element , self .item , True )
172164 tool .Blender .Modifier .Array .constrain_children_to_parent (element )
173165
174166 # clears the relating_array_object so it doesn't show again next time
175167 props .relating_array_object = None
176168
177- return {"FINISHED" }
178-
179169
180170class ApplyArray (bpy .types .Operator , tool .Ifc .Operator ):
181171 bl_idname = "bim.apply_array"
@@ -192,6 +182,33 @@ def _execute(self, context):
192182 return {"FINISHED" }
193183
194184
185+ class RegenerateArray (bpy .types .Operator , tool .Ifc .Operator ):
186+ bl_idname = "bim.regenerate_array"
187+ bl_label = "Regenerate Array"
188+ bl_options = {"REGISTER" , "UNDO" }
189+
190+ def _execute (self , context ):
191+ obj = context .active_object
192+ element = tool .Ifc .get_entity (obj )
193+ pset = ifcopenshell .util .element .get_pset (element , "BBIM_Array" )
194+ try :
195+ parent_element = tool .Ifc .get ().by_guid (pset ["Parent" ])
196+ parent = tool .Ifc .get_object (parent_element )
197+ except :
198+ return {"FINISHED" }
199+ pset = ifcopenshell .util .element .get_pset (parent_element , "BBIM_Array" )
200+ arrays = json .loads (pset ["Data" ])
201+ pset = tool .Ifc .get ().by_id (pset ["id" ])
202+ for array in arrays :
203+ for child in set (array ["children" ]):
204+ if child_obj := tool .Ifc .get_object (tool .Ifc .get ().by_guid (child )):
205+ tool .Geometry .delete_ifc_object (child_obj )
206+ array ["children" ].clear ()
207+ print ('cleared array' , arrays )
208+ tool .Model .regenerate_array (obj , arrays )
209+ tool .Blender .Modifier .Array .constrain_children_to_parent (element )
210+
211+
195212class RemoveArray (bpy .types .Operator , tool .Ifc .Operator ):
196213 bl_idname = "bim.remove_array"
197214 bl_label = "Remove Array"
@@ -216,7 +233,8 @@ def _execute(self, context):
216233 props .is_editing = - 1
217234
218235 try :
219- parent = tool .Ifc .get_object (tool .Ifc .get ().by_guid (pset ["Parent" ]))
236+ parent_element = tool .Ifc .get ().by_guid (pset ["Parent" ])
237+ parent = tool .Ifc .get_object (parent_element )
220238 except :
221239 return {"FINISHED" }
222240
@@ -226,9 +244,10 @@ def _execute(self, context):
226244
227245 if not self .keep_objs :
228246 data [self .item ]["count" ] = 1
247+ tool .Blender .Modifier .Array .remove_constraints (parent_element )
229248 tool .Model .regenerate_array (parent , data , array_layers_to_apply = [self .item ] if self .keep_objs else [])
230249
231- pset = tool .Ifc . get (). by_id ( pset [ "id" ] )
250+ pset = tool .Pset . get_element_pset ( element , "BBIM_Array" )
232251 if len (data ) == 1 :
233252 ifcopenshell .api .pset .remove_pset (tool .Ifc .get (), product = element , pset = pset )
234253 else :
@@ -237,8 +256,6 @@ def _execute(self, context):
237256 ifcopenshell .api .pset .edit_pset (tool .Ifc .get (), pset = pset , properties = {"Data" : data })
238257 tool .Blender .Modifier .Array .constrain_children_to_parent (element )
239258
240- return {"FINISHED" }
241-
242259
243260class SelectArrayParent (bpy .types .Operator ):
244261 bl_idname = "bim.select_array_parent"
0 commit comments