IO: Option to import each 3DS file on a new collection #105232
@ -1772,11 +1772,23 @@ def load_3ds(filepath, context, CONSTRAIN=10.0, UNITS=False, IMAGE_SEARCH=True,
|
|||||||
|
|
||||||
def load(operator, context, files=None, directory="", filepath="", constrain_size=0.0, use_scene_unit=False,
|
def load(operator, context, files=None, directory="", filepath="", constrain_size=0.0, use_scene_unit=False,
|
||||||
use_image_search=True, object_filter=None, use_world_matrix=False, use_keyframes=True,
|
use_image_search=True, object_filter=None, use_world_matrix=False, use_keyframes=True,
|
||||||
use_apply_transform=True, global_matrix=None, use_cursor=False, use_center_pivot=False):
|
use_apply_transform=True, global_matrix=None, use_cursor=False, use_center_pivot=False, new_collection=True):
|
||||||
|
|
||||||
for f in files:
|
# Get the active collection
|
||||||
|
collection_init = bpy.context.view_layer.active_layer_collection.collection
|
||||||
|
|
||||||
|
# Load each selected file
|
||||||
|
for file in files:
|
||||||
|
# Create new collections if activated (collection name = 3ds file name)
|
||||||
|
if new_collection:
|
||||||
NRGSille marked this conversation as resolved
|
|||||||
|
collection = bpy.data.collections.new(file.name)
|
||||||
|
bpy.context.scene.collection.children.link(collection)
|
||||||
|
bpy.context.view_layer.active_layer_collection = bpy.context.view_layer.layer_collection.children[collection.name]
|
||||||
load_3ds(os.path.join(directory, f.name), context, CONSTRAIN=constrain_size, UNITS=use_scene_unit,
|
load_3ds(os.path.join(directory, f.name), context, CONSTRAIN=constrain_size, UNITS=use_scene_unit,
|
||||||
IMAGE_SEARCH=use_image_search, FILTER=object_filter, WORLD_MATRIX=use_world_matrix, KEYFRAME=use_keyframes,
|
IMAGE_SEARCH=use_image_search, FILTER=object_filter, WORLD_MATRIX=use_world_matrix, KEYFRAME=use_keyframes,
|
||||||
APPLY_MATRIX=use_apply_transform, CONVERSE=global_matrix, CURSOR=use_cursor, PIVOT=use_center_pivot,)
|
APPLY_MATRIX=use_apply_transform, CONVERSE=global_matrix, CURSOR=use_cursor, PIVOT=use_center_pivot,)
|
||||||
|
|
||||||
|
# Retrive the initial collection as active
|
||||||
|
bpy.context.view_layer.active_layer_collection = bpy.context.view_layer.layer_collection.children[collection_init.name]
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
Loading…
Reference in New Issue
Block a user
found a little error in line 1784 (below) must be replaced with
if use_collection:
Yes, I forgot this fix.