Шрифт:
"author": "Thomas Larsson",
"location": "File > Import-Export",
"description": "Simple Wavefront obj import/export. Does meshes and UV coordinates",
"category": "Import-Export"}
# Для поддержки правильной перезагрузки, пробуем обратиться
# к переменной пакета, если она есть, перезагрузить всё
if "bpy" in locals:
import imp
if 'simple_obj_import' in locals:
imp.reload(simple_obj_import)
if 'simple_obj_export' in locals:
imp.reload(simple_obj_export)
import bpy
from bpy.props import *
from io_utils import ExportHelper, ImportHelper
#
# Меню Import
#
class IMPORT_OT_simple_obj(bpy.types.Operator, ImportHelper):
bl_idname = "io_import_scene.simple_obj"
bl_description = 'Import from simple OBJ file format (.obj)'
bl_label = "Import simple OBJ" bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
filename_ext = ".obj"
filter_glob = StringProperty(default="*.obj;*.mtl", options={'HIDDEN'})
filepath = bpy.props.StringProperty(
name="File Path",
description="File path used for importing the simple OBJ file",
maxlen= 1024, default= "")
rot90 = bpy.props.BoolProperty(
name = "Rotate 90 degrees",
description="Rotate mesh to Z up",
default = True)
scale = bpy.props.FloatProperty(
name = "Scale",
description="Scale mesh",
default = 0.1, min = 0.001, max = 1000.0)
def execute(self, context):
from . import simple_obj_import
print("Load", self.properties.filepath)
simple_obj_import.import_simple_obj(
self.properties.filepath,
self.rot90,
self.scale)
return {'FINISHED'}
def invoke(self, context, event):
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
#
# Меню Export
#
class EXPORT_OT_simple_obj(bpy.types.Operator, ExportHelper):
bl_idname = "io_export_scene.simple_obj"
bl_description = 'Export from simple OBJ file format (.obj)'
bl_label = "Export simple OBJ"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
# Из ExportHelper. Фильтрация имён файлов.
filename_ext = ".obj"
filter_glob = StringProperty(default="*.obj", options={'HIDDEN'})
filepath = bpy.props.StringProperty(
name="File Path",
description="File path used for exporting the simple OBJ file",
maxlen= 1024, default= "")
rot90 = bpy.props.BoolProperty(
name = "Rotate 90 degrees",
description="Rotate mesh to Y up",
default = True)
scale = bpy.props.FloatProperty(
name = "Scale",