@@ -50,7 +50,8 @@ def execute(self, context):
5050 fs = importer_prop .path + '/' + importer_prop .pattern
5151
5252 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 )))
5455 except Exception as e :
5556 show_message_box (traceback .format_exc (), "Can't find sequence: " + str (fs ), "ERROR" )
5657 return {"CANCELLED" }
@@ -522,7 +523,7 @@ def execute(self, context):
522523 return {'FINISHED' }
523524
524525class BSEQ_OT_load_all (bpy .types .Operator ):
525- """Load all sequences from selected folder"""
526+ """Load all sequences from selected folder and its subfolders """
526527 bl_idname = "bseq.load_all"
527528 bl_label = "Load All"
528529 bl_options = {'PRESET' , 'UNDO' }
@@ -533,8 +534,8 @@ def execute(self, context):
533534 if importer_prop .use_relative and not bpy .data .is_saved :
534535 return relative_path_error ()
535536
536- dir = importer_prop .path
537- seqs = fileseq .findSequencesOnDisk (str ( dir ))
537+ p = importer_prop .path
538+ seqs = fileseq .findSequencesOnDisk (bpy . path . abspath ( p ))
538539
539540 for s in seqs :
540541 print (s )
@@ -555,60 +556,56 @@ def execute(self, context):
555556 if importer_prop .use_relative and not bpy .data .is_saved :
556557 return relative_path_error ()
557558
558- root_dir = importer_prop .path
559+ root_dir = bpy . path . abspath ( importer_prop .path )
559560 root_coll = bpy .context .scene .collection
560561 root_layer_collection = bpy .context .view_layer .layer_collection
561562 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 :
601590 layer_collection = layer_collection .children [cur_coll .name ]
602591 last_coll = cur_coll
603592
604- # Set the last collection as the active collection by recursing through the collections
605- context .view_layer .active_layer_collection = layer_collection
606593
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)
609606
610- for s in seqs :
611- create_obj_wrapper (s , importer_prop )
607+ for s in seqs :
608+ create_obj_wrapper (s , importer_prop )
612609
613610 # Make sure unused datablocks are freed
614611 for coll in unlinked_collections :
0 commit comments