OSDN Git Service

add blender26-meshio
authorousttrue <ousttrue@gmail.com>
Wed, 12 Oct 2011 02:36:25 +0000 (11:36 +0900)
committerousttrue <ousttrue@gmail.com>
Wed, 12 Oct 2011 02:36:25 +0000 (11:36 +0900)
blender26-meshio/__init__.py [new file with mode: 0644]
blender26-meshio/import_pmx.py [new file with mode: 0644]
setup.py

diff --git a/blender26-meshio/__init__.py b/blender26-meshio/__init__.py
new file mode 100644 (file)
index 0000000..e58aa2c
--- /dev/null
@@ -0,0 +1,57 @@
+# coding: utf-8
+
+bl_info={
+        'category': 'Import-Export',
+        'name': 'extended MikuMikuDance model format(.pmx)',
+        'author': 'ousttrue',
+        'blender': (2, 6, 0),
+        'location': 'File > Import-Export',
+        'description': 'Import from the extended MikuMikuDance Model Format(.pmx)',
+        'warning': '', # used for warning icon and text in addons panel
+        'wiki_url': 'http://sourceforge.jp/projects/meshio/wiki/FrontPage',
+        }
+
+if "bpy" in locals():
+    import imp
+    if "import_pmx" in locals():
+        imp.reaload(import_pmx)
+
+
+import bpy
+import bpy_extras
+
+
+class ImportPMX(bpy.types.Operator, bpy_extras.io_utils.ImportHelper):
+    '''Import from the extended MikuMikuDance Model Format(.pmx)'''
+    bl_idname='import_scene.mmd_pmx'
+    bl_label='Import PMX'
+    bl_options={'UNDO'}
+    filename_ext='.pmx'
+    filter_glob=bpy.props.StringProperty(
+            default="*.pmx", options={'HIDDEN'})
+
+
+    def execute(self, context):
+        from . import import_pmx
+        keywords=self.as_keywords()
+        return import_pmx.load(self, context, **keywords)
+
+
+def menu_func_import(self, context):
+    self.layout.operator(ImportPMX.bl_idname, 
+            text="MikuMikuDance model (.pmx)",
+            icon='PLUGIN'
+            )
+
+def register():
+    bpy.utils.register_module(__name__)
+    bpy.types.INFO_MT_file_import.append(menu_func_import)
+
+def unregister():
+    bpy.utils.unregister_module(__name__)
+    bpy.types.INFO_MT_file_import.remove(menu_func_import)
+
+
+if __name__=="__main__":
+    register()
+
diff --git a/blender26-meshio/import_pmx.py b/blender26-meshio/import_pmx.py
new file mode 100644 (file)
index 0000000..8d1b4cd
--- /dev/null
@@ -0,0 +1,15 @@
+# coding: utf-8
+
+def load(operator, context, filepath, **kw):
+    print(filepath)
+    print(kw)
+
+    from .pymeshio.pmx import reader
+    model=reader.read_from_file(filepath)
+    if not model:
+        print("fail to load %s" % filepath)
+        return
+    print(model)
+
+    return {'FINISHED'}
+
index b4f76fc..bbed157 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -90,11 +90,18 @@ classifiers=[
         ]
 
 # copy pymeshio dir for blender25 plugin
-PYMESHIO_DIR_IN_BLENDER='blender25-meshio/pymeshio'
-if os.path.exists(PYMESHIO_DIR_IN_BLENDER):
-    shutil.rmtree(PYMESHIO_DIR_IN_BLENDER)    
-print("copy pymeshio to blender-25")
-shutil.copytree('pymeshio', PYMESHIO_DIR_IN_BLENDER)
+PYMESHIO_DIR_IN_BLENDER25='blender25-meshio/pymeshio'
+if os.path.exists(PYMESHIO_DIR_IN_BLENDER25):
+    shutil.rmtree(PYMESHIO_DIR_IN_BLENDER25)    
+print("copy pymeshio to %s" % PYMESHIO_DIR_IN_BLENDER25)
+shutil.copytree('pymeshio', PYMESHIO_DIR_IN_BLENDER25)
+# copy pymeshio dir for blender26 plugin
+PYMESHIO_DIR_IN_BLENDER26='blender26-meshio/pymeshio'
+if os.path.exists(PYMESHIO_DIR_IN_BLENDER26):
+    shutil.rmtree(PYMESHIO_DIR_IN_BLENDER26)    
+print("copy pymeshio to %s" % PYMESHIO_DIR_IN_BLENDER26)
+shutil.copytree('pymeshio', PYMESHIO_DIR_IN_BLENDER26)
+
 
 setup(
         name=name,