- use relative imports for packages
- reload() has been removed from pythons builtins. use imp.reload() instead (still need to apply globally). - fixed own mistake, not ignoring 'filter_glob' as a keyword argument (broke fbx, obj, 3ds export)
This commit is contained in:
@@ -26,9 +26,8 @@ data = _bpy.data
|
||||
context = _bpy.context
|
||||
|
||||
# python modules
|
||||
from bpy import utils, path
|
||||
|
||||
from bpy import ops as _ops_module
|
||||
from . import utils, path
|
||||
from . import ops as _ops_module
|
||||
|
||||
# fake operator module
|
||||
ops = _ops_module.ops_fake_module
|
||||
|
||||
@@ -23,13 +23,12 @@ This module contains utility functions specific to blender but
|
||||
not assosiated with blenders internal data.
|
||||
"""
|
||||
|
||||
import bpy as _bpy
|
||||
import os as _os
|
||||
import sys as _sys
|
||||
|
||||
from _bpy import blend_paths, user_resource
|
||||
from _bpy import script_paths as _bpy_script_paths
|
||||
|
||||
import bpy as _bpy
|
||||
import os as _os
|
||||
import sys as _sys
|
||||
|
||||
def _test_import(module_name, loaded_modules):
|
||||
import traceback
|
||||
|
||||
@@ -83,6 +83,9 @@ def get_console(console_id):
|
||||
namespace["bpy"] = bpy
|
||||
namespace["C"] = bpy.context
|
||||
|
||||
namespace.update(__import__("mathutils").__dict__) # from mathutils import *
|
||||
namespace.update(__import__("math").__dict__) # from math import *
|
||||
|
||||
console = InteractiveConsole(locals=namespace, filename="<blender_console>")
|
||||
|
||||
if _BPY_MAIN_OWN:
|
||||
@@ -263,6 +266,7 @@ def banner(context):
|
||||
add_scrollback("Autocomplete: Ctrl+Space", 'OUTPUT')
|
||||
add_scrollback("Ctrl +/- Wheel: Zoom", 'OUTPUT')
|
||||
add_scrollback("Builtin Modules: bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bgl, blf, mathutils", 'OUTPUT')
|
||||
add_scrollback("Convenience Imports: from mathutils import *; from math import *", 'OUTPUT')
|
||||
add_scrollback("", 'OUTPUT')
|
||||
add_scrollback(" WARNING!!! Blender 2.5 API is subject to change, see API reference for more info.", 'ERROR')
|
||||
add_scrollback("", 'OUTPUT')
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
# To support reload properly, try to access a package var, if it's there, reload everything
|
||||
if "bpy" in locals():
|
||||
# only reload if we alredy loaded, highly annoying
|
||||
import sys
|
||||
reload(sys.modules.get("io_anim_bvh.import_bvh", sys))
|
||||
from imp import reload
|
||||
if "import_bvh" in locals():
|
||||
reload(import_bvh)
|
||||
|
||||
|
||||
import bpy
|
||||
@@ -56,8 +56,8 @@ class BvhImporter(bpy.types.Operator, ImportHelper):
|
||||
default='NATIVE')
|
||||
|
||||
def execute(self, context):
|
||||
import io_anim_bvh.import_bvh
|
||||
return io_anim_bvh.import_bvh.load(self, context, **self.as_keywords(ignore=("filter_glob",)))
|
||||
from . import import_bvh
|
||||
return import_bvh.load(self, context, **self.as_keywords(ignore=("filter_glob",)))
|
||||
|
||||
|
||||
def menu_func(self, context):
|
||||
|
||||
@@ -18,8 +18,9 @@
|
||||
|
||||
# To support reload properly, try to access a package var, if it's there, reload everything
|
||||
if "bpy" in locals():
|
||||
import sys
|
||||
reload(sys.modules.get("io_mesh_ply.export_ply", sys))
|
||||
from imp import reload
|
||||
if "export_ply" in locals():
|
||||
reload(export_ply)
|
||||
|
||||
|
||||
import bpy
|
||||
@@ -47,8 +48,8 @@ class ExportPLY(bpy.types.Operator, ExportHelper):
|
||||
def execute(self, context):
|
||||
filepath = self.filepath
|
||||
filepath = bpy.path.ensure_ext(filepath, self.filename_ext)
|
||||
import io_mesh_ply.export_ply
|
||||
return io_mesh_ply.export_ply.save(self, context, **self.as_keywords(ignore=("check_existing",)))
|
||||
from . import export_ply
|
||||
return export_ply.save(self, context, **self.as_keywords(ignore=("check_existing", "filter_glob")))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -20,9 +20,11 @@
|
||||
|
||||
# To support reload properly, try to access a package var, if it's there, reload everything
|
||||
if "bpy" in locals():
|
||||
import sys
|
||||
reload(sys.modules.get("io_scene_3ds.import_3ds", sys))
|
||||
reload(sys.modules.get("io_scene_3ds.export_3ds", sys))
|
||||
from imp import reload
|
||||
if "import_3ds" in locals():
|
||||
reload(import_3ds)
|
||||
if "export_3ds" in locals():
|
||||
reload(export_3ds)
|
||||
|
||||
|
||||
import bpy
|
||||
@@ -43,8 +45,8 @@ class Import3DS(bpy.types.Operator, ImportHelper):
|
||||
use_apply_transform = BoolProperty(name="Apply Transform", description="Workaround for object transformations importing incorrectly", default=True)
|
||||
|
||||
def execute(self, context):
|
||||
import io_scene_3ds.import_3ds
|
||||
return io_scene_3ds.import_3ds.load(self, context, **self.as_keywords(ignore=("filter_glob",)))
|
||||
from . import import_3ds
|
||||
return import_3ds.load(self, context, **self.as_keywords(ignore=("filter_glob",)))
|
||||
|
||||
|
||||
class Export3DS(bpy.types.Operator, ExportHelper):
|
||||
@@ -56,8 +58,8 @@ class Export3DS(bpy.types.Operator, ExportHelper):
|
||||
filter_glob = StringProperty(default="*.3ds", options={'HIDDEN'})
|
||||
|
||||
def execute(self, context):
|
||||
import io_scene_3ds.export_3ds
|
||||
return io_scene_3ds.export_3ds.save(self, context, **self.as_keywords(ignore=("check_existing",)))
|
||||
from . import export_3ds
|
||||
return export_3ds.save(self, context, **self.as_keywords(ignore=("check_existing", "filter_glob")))
|
||||
|
||||
|
||||
# Add to a menu
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
# To support reload properly, try to access a package var, if it's there, reload everything
|
||||
if "bpy" in locals():
|
||||
# only reload if we alredy loaded, highly annoying
|
||||
import sys
|
||||
reload(sys.modules.get("io_scene_fbx.export_fbx", sys))
|
||||
from imp import reload
|
||||
if "export_fbx" in locals():
|
||||
reload(export_fbx)
|
||||
|
||||
|
||||
import bpy
|
||||
@@ -87,7 +87,7 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
|
||||
GLOBAL_MATRIX = mtx4_z90n * GLOBAL_MATRIX
|
||||
|
||||
import io_scene_fbx.export_fbx
|
||||
return io_scene_fbx.export_fbx.save(self, context, **self.as_keywords(ignore=("TX_XROT90", "TX_YROT90", "TX_ZROT90", "TX_SCALE", "check_existing")))
|
||||
return io_scene_fbx.export_fbx.save(self, context, **self.as_keywords(ignore=("TX_XROT90", "TX_YROT90", "TX_ZROT90", "TX_SCALE", "check_existing", "filter_glob")))
|
||||
|
||||
|
||||
def menu_func(self, context):
|
||||
|
||||
@@ -20,10 +20,11 @@
|
||||
|
||||
# To support reload properly, try to access a package var, if it's there, reload everything
|
||||
if "bpy" in locals():
|
||||
# only reload if we alredy loaded, highly annoying
|
||||
import sys
|
||||
reload(sys.modules.get("io_scene_obj.import_obj", sys))
|
||||
reload(sys.modules.get("io_scene_obj.export_obj", sys))
|
||||
from imp import reload
|
||||
if "import_obj" in locals():
|
||||
reload(import_obj)
|
||||
if "export_obj" in locals():
|
||||
reload(export_obj)
|
||||
|
||||
|
||||
import bpy
|
||||
@@ -55,8 +56,8 @@ class ImportOBJ(bpy.types.Operator, ImportHelper):
|
||||
|
||||
def execute(self, context):
|
||||
# print("Selected: " + context.active_object.name)
|
||||
import io_scene_obj.import_obj
|
||||
return io_scene_obj.import_obj.load(self, context, **self.as_keywords(ignore=("filter_glob",)))
|
||||
from . import import_obj
|
||||
return import_obj.load(self, context, **self.as_keywords(ignore=("filter_glob",)))
|
||||
|
||||
|
||||
class ExportOBJ(bpy.types.Operator, ExportHelper):
|
||||
@@ -99,8 +100,8 @@ class ExportOBJ(bpy.types.Operator, ExportHelper):
|
||||
|
||||
|
||||
def execute(self, context):
|
||||
import io_scene_obj.export_obj
|
||||
return io_scene_obj.export_obj.save(self, context, **self.as_keywords(ignore=("check_existing",)))
|
||||
from . import export_obj
|
||||
return export_obj.save(self, context, **self.as_keywords(ignore=("check_existing", "filter_glob")))
|
||||
|
||||
|
||||
def menu_func_import(self, context):
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
# To support reload properly, try to access a package var, if it's there, reload everything
|
||||
if "bpy" in locals():
|
||||
# only reload if we alredy loaded, highly annoying
|
||||
import sys
|
||||
reload(sys.modules.get("io_scene_x3d.export_x3d", sys))
|
||||
from imp import reload
|
||||
if "export_x3d" in locals():
|
||||
reload(export_x3d)
|
||||
|
||||
|
||||
import bpy
|
||||
@@ -41,8 +41,8 @@ class ExportX3D(bpy.types.Operator, ExportHelper):
|
||||
use_compress = BoolProperty(name="Compress", description="GZip the resulting file, requires a full python install", default=False)
|
||||
|
||||
def execute(self, context):
|
||||
import io_scene_x3d.export_x3d
|
||||
return io_scene_x3d.export_x3d.save(self, context, **self.as_keywords(ignore=("check_existing",)))
|
||||
from . import export_x3d
|
||||
return export_x3d.save(self, context, **self.as_keywords(ignore=("check_existing", "filter_glob")))
|
||||
|
||||
|
||||
def menu_func(self, context):
|
||||
|
||||
@@ -20,10 +20,11 @@
|
||||
|
||||
# To support reload properly, try to access a package var, if it's there, reload everything
|
||||
if "bpy" in locals():
|
||||
# only reload if we alredy loaded, highly annoying
|
||||
import sys
|
||||
reload(sys.modules.get("io_shape_mdd.import_mdd", sys))
|
||||
reload(sys.modules.get("io_shape_mdd.export_mdd", sys))
|
||||
from imp import reload
|
||||
if "import_mdd" in locals():
|
||||
reload(import_mdd)
|
||||
if "export_mdd" in locals():
|
||||
reload(export_mdd)
|
||||
|
||||
|
||||
import bpy
|
||||
@@ -54,8 +55,8 @@ class ImportMDD(bpy.types.Operator, ImportHelper):
|
||||
if not self.frame_start:
|
||||
self.frame_start = scene.frame_current
|
||||
|
||||
import io_shape_mdd.import_mdd
|
||||
return io_shape_mdd.import_mdd.load(self, context, **self.as_keywords(ignore=("filter_glob",)))
|
||||
from . import import_mdd
|
||||
return import_mdd.load(self, context, **self.as_keywords(ignore=("filter_glob",)))
|
||||
|
||||
class ExportMDD(bpy.types.Operator, ExportHelper):
|
||||
'''Animated mesh to MDD vertex keyframe file'''
|
||||
@@ -93,8 +94,8 @@ class ExportMDD(bpy.types.Operator, ExportHelper):
|
||||
if not self.fps:
|
||||
self.fps = scene.render.fps
|
||||
|
||||
import io_shape_mdd.export_mdd
|
||||
return io_shape_mdd.export_mdd.save(self, context, **self.as_keywords(ignore=("check_existing",)))
|
||||
from . import export_mdd
|
||||
return export_mdd.save(self, context, **self.as_keywords(ignore=("check_existing", "filter_glob")))
|
||||
|
||||
|
||||
def menu_func_import(self, context):
|
||||
|
||||
Reference in New Issue
Block a user