.obj additional exporters/importers
This commit is contained in:
parent
1fb7077774
commit
47773be8d4
5 changed files with 49 additions and 6 deletions
1
cg/blender/import_mesh/README.md
Normal file
1
cg/blender/import_mesh/README.md
Normal file
|
@ -0,0 +1 @@
|
|||
## Модули импорта для Blender
|
7
cg/blender/import_mesh/__init__.py
Normal file
7
cg/blender/import_mesh/__init__.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
DESCRIPTION.
|
||||
Blender export modules.
|
||||
Modules exports all objests in scene.
|
||||
You can set export path and subdir.
|
||||
"""
|
29
cg/blender/import_mesh/obj.py
Normal file
29
cg/blender/import_mesh/obj.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
DESCRIPTION.
|
||||
OBJ mesh importer.
|
||||
Import files in blender scene.
|
||||
"""
|
||||
__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!")
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue