.obj additional exporters/importers
This commit is contained in:
parent
1fb7077774
commit
47773be8d4
5 changed files with 49 additions and 6 deletions
|
@ -5,10 +5,9 @@ OBJ mesh exporter.
|
|||
Exports all objects in scene.
|
||||
You can set export path and subdir.
|
||||
"""
|
||||
__version__ = "0.1"
|
||||
__version__ = "0.2"
|
||||
|
||||
import logging
|
||||
import sys
|
||||
import bpy
|
||||
import os
|
||||
|
||||
|
@ -16,19 +15,22 @@ logger = logging.getLogger(__name__)
|
|||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
def export_obj(path, subdir=""):
|
||||
def export_obj(path, subdir="", filename=None):
|
||||
""" OBJ mesh exporter. Exports all objects in scene. """
|
||||
for ob in bpy.context.scene.objects:
|
||||
# deselect all but just one object and make it active
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
ob.select_set(state=True)
|
||||
bpy.context.view_layer.objects.active = ob
|
||||
filename = bpy.context.active_object.name
|
||||
if not filename:
|
||||
filename = bpy.context.active_object.name
|
||||
if not filename.endswith('.obj'):
|
||||
filename = (filename + '.obj')
|
||||
# export obj
|
||||
obj_path = os.path.join(path, subdir).replace('\\', '/')
|
||||
if not os.path.isdir(obj_path):
|
||||
os.makedirs(obj_path)
|
||||
outpath = os.path.join(obj_path, filename)
|
||||
logger.debug('vizual:', outpath)
|
||||
logger.debug('Exporting to %s', outpath)
|
||||
|
||||
bpy.ops.wm.obj_export(filepath=outpath, forward_axis='Y', up_axis='Z', global_scale=1000, apply_modifiers=True, export_selected_objects=True, export_uv=True, export_normals=True, export_colors=False, export_materials=True, export_pbr_extensions=False, path_mode='AUTO', export_triangulated_mesh=True)
|
||||
return bpy.ops.wm.obj_export(filepath=outpath, forward_axis='Y', up_axis='Z', global_scale=1000, apply_modifiers=True, export_selected_objects=True, export_uv=True, export_normals=True, export_colors=False, export_materials=True, export_pbr_extensions=False, path_mode='AUTO', export_triangulated_mesh=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue