IO: Option to import each 3DS file on a new collection #105232
@ -10,6 +10,7 @@ import struct
|
|||||||
import mathutils
|
import mathutils
|
||||||
from bpy_extras.image_utils import load_image
|
from bpy_extras.image_utils import load_image
|
||||||
from bpy_extras.node_shader_utils import PrincipledBSDFWrapper
|
from bpy_extras.node_shader_utils import PrincipledBSDFWrapper
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
BOUNDS_3DS = []
|
BOUNDS_3DS = []
|
||||||
|
|
||||||
@ -1772,7 +1773,7 @@ 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,
|
||||||
RobLop marked this conversation as resolved
Outdated
|
|||||||
use_apply_transform=True, global_matrix=None, use_cursor=False, use_center_pivot=False, new_collection=True):
|
use_apply_transform=True, global_matrix=None, use_cursor=False, use_center_pivot=False, use_collection=False):
|
||||||
|
|
||||||
# Get the active collection
|
# Get the active collection
|
||||||
collection_init = bpy.context.view_layer.active_layer_collection.collection
|
collection_init = bpy.context.view_layer.active_layer_collection.collection
|
||||||
@ -1781,10 +1782,10 @@ def load(operator, context, files=None, directory="", filepath="", constrain_siz
|
|||||||
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
Sebastian Sille
commented
found a little error in line 1784 (below) must be replaced with found a little error in line 1784 (below) must be replaced with `if use_collection:`
RobLop
commented
Yes, I forgot this fix. Yes, I forgot this fix.
|
|||||||
if new_collection:
|
if new_collection:
|
||||||
RobLop marked this conversation as resolved
Outdated
Sebastian Sille
commented
Looks better if we- use it without suffix. Can be achieved with Looks better if we- use it without suffix. Can be achieved with `file.name.split(".")[0]`
RobLop
commented
Ok, achieved with Path().stem (modern way). Ok, achieved with Path().stem (modern way).
|
|||||||
collection = bpy.data.collections.new(file.name)
|
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
Sebastian Sille
commented
Here is a little error, it must be Here is a little error, it must be `os.path.join(directory, file.name)`
RobLop
commented
Ok, corrected with the Path(). Ok, corrected with the Path().
|
|||||||
load_3ds(os.path.join(directory, f.name), context, CONSTRAIN=constrain_size, UNITS=use_scene_unit,
|
load_3ds(Path(directory, file.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,)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user
Set default to False