@@ -50,7 +50,8 @@ def execute(self, context):
50
50
fs = importer_prop .path + '/' + importer_prop .pattern
51
51
52
52
try :
53
- fs = fileseq .findSequenceOnDisk (fs )
53
+ # Call os.path.abspath in addition because findSequenceOnDisk does not support \..\ components on Windows apparently
54
+ fs = fileseq .findSequenceOnDisk (os .path .abspath (bpy .path .abspath (fs )))
54
55
except Exception as e :
55
56
show_message_box (traceback .format_exc (), "Can't find sequence: " + str (fs ), "ERROR" )
56
57
return {"CANCELLED" }
@@ -522,7 +523,7 @@ def execute(self, context):
522
523
return {'FINISHED' }
523
524
524
525
class BSEQ_OT_load_all (bpy .types .Operator ):
525
- """Load all sequences from selected folder"""
526
+ """Load all sequences from selected folder and its subfolders """
526
527
bl_idname = "bseq.load_all"
527
528
bl_label = "Load All"
528
529
bl_options = {'PRESET' , 'UNDO' }
@@ -533,8 +534,8 @@ def execute(self, context):
533
534
if importer_prop .use_relative and not bpy .data .is_saved :
534
535
return relative_path_error ()
535
536
536
- dir = importer_prop .path
537
- seqs = fileseq .findSequencesOnDisk (str ( dir ))
537
+ p = importer_prop .path
538
+ seqs = fileseq .findSequencesOnDisk (bpy . path . abspath ( p ))
538
539
539
540
for s in seqs :
540
541
print (s )
@@ -555,60 +556,56 @@ def execute(self, context):
555
556
if importer_prop .use_relative and not bpy .data .is_saved :
556
557
return relative_path_error ()
557
558
558
- root_dir = importer_prop .path
559
+ root_dir = bpy . path . abspath ( importer_prop .path )
559
560
root_coll = bpy .context .scene .collection
560
561
root_layer_collection = bpy .context .view_layer .layer_collection
561
562
unlinked_collections = []
562
- # Recurse through subdirectories
563
- for root , dirs , files in os .walk (bpy .path .abspath (root_dir )):
564
- for dir in sorted (dirs ):
565
- # Process subdirectory
566
- subdirectory = os .path .join (root , dir )
567
-
568
- seqs = fileseq .findSequencesOnDisk (subdirectory )
569
- if len (seqs ) == 0 :
570
- continue
571
-
572
- # Get list of directories from the root_dir to the current subdirectory
573
- coll_list = bpy .path .relpath (subdirectory , start = root_dir ).strip ("//" ).split ("/" )
574
-
575
- # Get or create a nested collection starting from the root
576
- last_coll = root_coll
577
- layer_collection = root_layer_collection
578
- for coll in coll_list :
579
- # If it already exists and is not in the children of the last collection, then the prefix has changed
580
- cur_coll = bpy .data .collections .get (coll )
581
- if cur_coll is not None and last_coll is not None :
582
- if cur_coll .name not in last_coll .children :
583
- # Get the old parent of the existing collection and move the children to the old parent
584
- parent = [c for c in bpy .data .collections if bpy .context .scene .user_of_id (cur_coll ) and cur_coll .name in c .children ]
585
- if len (parent ) > 0 :
586
- for child in cur_coll .children :
587
- parent [0 ].children .link (child )
588
- for obj in cur_coll .objects :
589
- parent [0 ].objects .link (obj )
590
- parent [0 ].children .unlink (cur_coll )
591
- unlinked_collections .append (cur_coll )
592
- else :
593
- layer_collection = layer_collection .children [cur_coll .name ]
594
- last_coll = cur_coll
595
-
596
-
597
- # If it was newly created, link it to the last collection
598
- if cur_coll is None and last_coll is not None :
599
- cur_coll = bpy .data .collections .new (coll )
600
- last_coll .children .link (cur_coll )
563
+ # Recurse through directory itself and subdirectories
564
+ for current_dir , subdirs , files in os .walk (root_dir ):
565
+ seqs = fileseq .findSequencesOnDisk (current_dir )
566
+ if len (seqs ) == 0 :
567
+ continue
568
+
569
+ # Get list of directories from the root_dir to the current directory
570
+ coll_list = bpy .path .relpath (current_dir , start = root_dir ).strip ("//" ).split ("/" )
571
+
572
+ # Get or create a nested collection starting from the root
573
+ last_coll = root_coll
574
+ layer_collection = root_layer_collection
575
+ for coll in coll_list :
576
+ # If it already exists and is not in the children of the last collection, then the prefix has changed
577
+ cur_coll = bpy .data .collections .get (coll )
578
+ if cur_coll is not None and last_coll is not None :
579
+ if cur_coll .name not in last_coll .children :
580
+ # Get the old parent of the existing collection and move the children to the old parent
581
+ parent = [c for c in bpy .data .collections if bpy .context .scene .user_of_id (cur_coll ) and cur_coll .name in c .children ]
582
+ if len (parent ) > 0 :
583
+ for child in cur_coll .children :
584
+ parent [0 ].children .link (child )
585
+ for obj in cur_coll .objects :
586
+ parent [0 ].objects .link (obj )
587
+ parent [0 ].children .unlink (cur_coll )
588
+ unlinked_collections .append (cur_coll )
589
+ else :
601
590
layer_collection = layer_collection .children [cur_coll .name ]
602
591
last_coll = cur_coll
603
592
604
- # Set the last collection as the active collection by recursing through the collections
605
- context .view_layer .active_layer_collection = layer_collection
606
593
607
- # for s in seqs:
608
- # print(s)
594
+ # If it was newly created, link it to the last collection
595
+ if cur_coll is None and last_coll is not None :
596
+ cur_coll = bpy .data .collections .new (coll )
597
+ last_coll .children .link (cur_coll )
598
+ layer_collection = layer_collection .children [cur_coll .name ]
599
+ last_coll = cur_coll
600
+
601
+ # Set the last collection as the active collection by recursing through the collections
602
+ context .view_layer .active_layer_collection = layer_collection
603
+
604
+ # for s in seqs:
605
+ # print(s)
609
606
610
- for s in seqs :
611
- create_obj_wrapper (s , importer_prop )
607
+ for s in seqs :
608
+ create_obj_wrapper (s , importer_prop )
612
609
613
610
# Make sure unused datablocks are freed
614
611
for coll in unlinked_collections :
0 commit comments