framework/cg/blender/import_mesh/obj.py

31 lines
881 B
Python
Raw Normal View History

2023-06-18 15:30:44 +00:00
# -*- coding: utf-8 -*-
"""
DESCRIPTION.
OBJ mesh importer.
Import files in blender scene.
2023-11-13 13:07:33 +00:00
DEPRECATED
2023-06-18 15:30:44 +00:00
"""
__version__ = "0.2"
import logging
import bpy
import os
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
def import_obj(path):
bpy.ops.object.select_all(action='DESELECT')
path = path.replace('\\', '/')
if os.path.isfile(path) and path.endswith('.obj'):
return bpy.ops.wm.obj_import(filepath=path, global_scale=0.001, clamp_size=0, forward_axis='Y', up_axis='Z')
if os.path.isdir(path):
file_list = sorted(os.listdir(path))
obj_list = [dict(name=item) for item in file_list if item.endswith('.obj')]
return bpy.ops.wm.obj_import(directory=path, files=obj_list, global_scale=0.001, clamp_size=0, forward_axis='Y', up_axis='Z')
return logger.info("Path must be a directory or *.obj file!")