IO: Option to import each 3DS file on a new collection #105232

Merged
Sebastian Sille merged 6 commits from :roblop-patch-new-collection into main 2024-03-13 13:34:08 +01:00
Showing only changes of commit 98e970577c - Show all commits

View File

@ -1781,7 +1781,7 @@ def load(operator, context, files=None, directory="", filepath="", constrain_siz
# Load each selected file # Load each selected file
for file in files: for file in files:
# Create new collections if activated (collection name = 3ds file name) # Create new collections if activated (collection name = 3ds file name)
NRGSille marked this conversation as resolved
Review

found a little error in line 1784 (below) must be replaced with if use_collection:

found a little error in line 1784 (below) must be replaced with `if use_collection:`
Review

Yes, I forgot this fix.

Yes, I forgot this fix.
if new_collection: if use_collection:
RobLop marked this conversation as resolved Outdated

Looks better if we- use it without suffix. Can be achieved with file.name.split(".")[0]

Looks better if we- use it without suffix. Can be achieved with `file.name.split(".")[0]`

Ok, achieved with Path().stem (modern way).

Ok, achieved with Path().stem (modern way).
collection = bpy.data.collections.new(Path(file.name).stem) collection = bpy.data.collections.new(Path(file.name).stem)
bpy.context.scene.collection.children.link(collection) bpy.context.scene.collection.children.link(collection)
bpy.context.view_layer.active_layer_collection = bpy.context.view_layer.layer_collection.children[collection.name] bpy.context.view_layer.active_layer_collection = bpy.context.view_layer.layer_collection.children[collection.name]
RobLop marked this conversation as resolved Outdated

Here is a little error, it must be os.path.join(directory, file.name)

Here is a little error, it must be `os.path.join(directory, file.name)`

Ok, corrected with the Path().

Ok, corrected with the Path().