@@ -156,15 +156,17 @@ def do_versioning(self):
156
156
# Dictionary to temporarily store objects and their modifiers
157
157
old_objects = {}
158
158
159
+ # First pass: store old objects and change conversion type
159
160
for sketch in context .scene .sketcher .entities .sketches :
160
161
if sketch .convert_type == 'NONE' :
161
162
continue
162
163
163
- # Store references to the old objects before deleting them
164
+ # Store references to the old objects
164
165
sketch_id = str (sketch .slvs_index )
165
166
old_objects [sketch_id ] = {
166
167
'mesh_obj' : sketch .target_object ,
167
- 'curve_obj' : sketch .target_curve_object
168
+ 'curve_obj' : sketch .target_curve_object ,
169
+ 'sketch' : sketch
168
170
}
169
171
170
172
# Clear links to objects but don't delete them yet
@@ -181,21 +183,24 @@ def do_versioning(self):
181
183
182
184
msg += " {}" .format (str (sketch ))
183
185
184
- # Trigger the conversion with the new convert type
185
- bpy .ops .view3d .slvs_update (solve = False )
186
+ # Second pass: process each sketch individually
187
+ for sketch_id , objects in old_objects .items ():
188
+ sketch = objects ['sketch' ]
186
189
187
- # Now copy modifiers from old objects to new objects
188
- for sketch in context .scene .sketcher .entities .sketches :
189
- sketch_id = str (sketch .slvs_index )
190
- if sketch_id not in old_objects :
191
- continue
190
+ # Force creation of converted object for this sketch
191
+ bpy .ops .view3d .slvs_update (solve = False )
192
192
193
+ # Ensure the new object is created
193
194
if sketch .target_curve_object :
194
195
# Try to copy from mesh object first, then curve object
195
- if old_objects [sketch_id ]['mesh_obj' ]:
196
- copy_modifiers (old_objects [sketch_id ]['mesh_obj' ], sketch .target_curve_object )
197
- elif old_objects [sketch_id ]['curve_obj' ]:
198
- copy_modifiers (old_objects [sketch_id ]['curve_obj' ], sketch .target_curve_object )
196
+ if objects ['mesh_obj' ]:
197
+ copy_modifiers (objects ['mesh_obj' ], sketch .target_curve_object )
198
+ elif objects ['curve_obj' ]:
199
+ copy_modifiers (objects ['curve_obj' ], sketch .target_curve_object )
200
+
201
+ logger .info (f"Copied modifiers to new object for sketch { sketch_id } " )
202
+ else :
203
+ logger .warning (f"Failed to create new object for sketch { sketch_id } " )
199
204
200
205
# Unlink and rename old objects instead of deleting them
201
206
for sketch_id , objects in old_objects .items ():
@@ -206,7 +211,7 @@ def do_versioning(self):
206
211
for collection in old_obj .users_collection :
207
212
collection .objects .unlink (old_obj )
208
213
# Rename to indicate it's an old version
209
- old_obj .name = f"OLD_{ old_obj .name } "
214
+ old_obj .name = f"OLD_{ old_obj .name } _ { sketch_id } "
210
215
211
216
# Process curve object
212
217
if objects ['curve_obj' ]:
@@ -215,6 +220,6 @@ def do_versioning(self):
215
220
for collection in old_obj .users_collection :
216
221
collection .objects .unlink (old_obj )
217
222
# Rename to indicate it's an old version
218
- old_obj .name = f"OLD_{ old_obj .name } "
223
+ old_obj .name = f"OLD_{ old_obj .name } _ { sketch_id } "
219
224
220
225
logger .warning (msg )
0 commit comments