@@ -94,6 +94,9 @@ def update_mesh(meshio_mesh, mesh):
94
94
n_loop = 0
95
95
n_verts = len (mesh_vertices )
96
96
if n_verts == 0 :
97
+ mesh .clear_geometry ()
98
+ mesh .update ()
99
+ mesh .validate ()
97
100
return
98
101
faces_loop_start = np .array ([], dtype = np .uint64 )
99
102
faces_loop_total = np .array ([], dtype = np .uint64 )
@@ -202,11 +205,14 @@ def create_obj(fileseq, use_relative, root_path, transform_matrix=Matrix([[1, 0,
202
205
current_frame = bpy .context .scene .frame_current
203
206
filepath = fileseq [current_frame % len (fileseq )]
204
207
205
- if filepath .endswith (".obj" ):
208
+ #.obj sequences have to be handled differently
209
+ isObj = filepath .endswith (".obj" )
210
+ if isObj :
206
211
bpy .ops .import_scene .obj (filepath = filepath )
207
212
object = bpy .context .selected_objects [- 1 ]
208
213
object .name = fileseq .basename () + "@" + fileseq .extension ()
209
- enabled = False
214
+ # object.data.name = fileseq.basename() + "@" + fileseq.extension()
215
+ enabled = True
210
216
else :
211
217
meshio_mesh = None
212
218
enabled = True
@@ -237,6 +243,8 @@ def create_obj(fileseq, use_relative, root_path, transform_matrix=Matrix([[1, 0,
237
243
object .matrix_world = transform_matrix
238
244
driver = object .driver_add ("BSEQ.frame" )
239
245
driver .driver .expression = 'frame'
246
+ if isObj :
247
+ return
240
248
if enabled :
241
249
update_mesh (meshio_mesh , object .data )
242
250
bpy .context .collection .objects .link (object )
@@ -249,6 +257,9 @@ def update_obj(scene, depsgraph=None):
249
257
for obj in bpy .data .objects :
250
258
start_time = time .perf_counter ()
251
259
260
+ isObj = obj .BSEQ .pattern .endswith (".obj" )
261
+ print ("isObj: " , isObj )
262
+
252
263
if obj .BSEQ .init == False :
253
264
continue
254
265
if obj .BSEQ .enabled == False :
@@ -305,14 +316,23 @@ def update_obj(scene, depsgraph=None):
305
316
else :
306
317
filepath = fs [current_frame % len (fs )]
307
318
try :
308
- meshio_mesh = meshio .read (filepath )
319
+ if filepath .endswith (".obj" ):
320
+ # Reload the object
321
+ obj .select_set (True )
322
+ bpy .ops .object .delete ()
323
+ # bpy.ops.import_scene.obj(filepath=filepath)
324
+ # object = bpy.context.selected_objects[-1]
325
+ # object.name = fileseq.basename() + "@" + fileseq.extension()
326
+ # object.data.name = fileseq.basename() + "@" + fileseq.extension()
327
+ else :
328
+ meshio_mesh = meshio .read (filepath )
309
329
except Exception as e :
310
330
show_message_box ("Error when reading: " + filepath + ",\n " + traceback .format_exc (),
311
331
"Meshio Loading Error" + str (e ),
312
332
icon = "ERROR" )
313
333
continue
314
334
315
- if not isinstance (meshio_mesh , meshio .Mesh ):
335
+ if not isinstance (meshio_mesh , meshio .Mesh ) or not isObj :
316
336
show_message_box ('function preprocess does not return meshio object' , "ERROR" )
317
337
continue
318
338
update_mesh (meshio_mesh , obj .data )
0 commit comments