diff options
author | Nathan Letwory <nathan@letworyinteractive.com> | 2011-04-12 22:37:50 +0400 |
---|---|---|
committer | Nathan Letwory <nathan@letworyinteractive.com> | 2011-04-12 22:37:50 +0400 |
commit | 15f17383a331c0f217ba532e6dd927592dcae4c7 (patch) | |
tree | d868d69d3fe390c23737304dce7ecb9ee3393e8c /io_scene_x3d/__init__.py |
Tag trunk/py (addons) for 2.57 releasev2.57
Diffstat (limited to 'io_scene_x3d/__init__.py')
-rw-r--r-- | io_scene_x3d/__init__.py | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/io_scene_x3d/__init__.py b/io_scene_x3d/__init__.py new file mode 100644 index 00000000..f49cebaf --- /dev/null +++ b/io_scene_x3d/__init__.py @@ -0,0 +1,103 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# <pep8 compliant> + +bl_info = { + "name": "Web3D X3D/VRML format", + "author": "Campbell Barton, Bart", + "blender": (2, 5, 7), + "api": 35622, + "location": "File > Import-Export", + "description": "Import-Export X3D, Import VRML", + "warning": "", + "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\ + "Scripts/Import-Export/Web3D", + "tracker_url": "", + "support": 'OFFICIAL', + "category": "Import-Export"} + +# To support reload properly, try to access a package var, if it's there, reload everything +if "bpy" in locals(): + import imp + if "export_x3d" in locals(): + imp.reload(export_x3d) + + +import bpy +from bpy.props import StringProperty, BoolProperty +from io_utils import ImportHelper, ExportHelper + + +class ImportX3D(bpy.types.Operator, ImportHelper): + '''Load a BVH motion capture file''' + bl_idname = "import_scene.x3d" + bl_label = "Import X3D/VRML" + + filename_ext = ".x3d" + filter_glob = StringProperty(default="*.x3d;*.wrl", options={'HIDDEN'}) + + def execute(self, context): + from . import import_x3d + return import_x3d.load(self, context, **self.as_keywords(ignore=("filter_glob",))) + + +class ExportX3D(bpy.types.Operator, ExportHelper): + '''Export selection to Extensible 3D file (.x3d)''' + bl_idname = "export_scene.x3d" + bl_label = 'Export X3D' + + filename_ext = ".x3d" + filter_glob = StringProperty(default="*.x3d", options={'HIDDEN'}) + + use_selection = BoolProperty(name="Selection Only", description="Export selected objects only", default=False) + use_apply_modifiers = BoolProperty(name="Apply Modifiers", description="Use transformed mesh data from each object", default=True) + use_triangulate = BoolProperty(name="Triangulate", description="Triangulate quads.", default=False) + use_compress = BoolProperty(name="Compress", description="GZip the resulting file, requires a full python install", default=False) + + def execute(self, context): + from . import export_x3d + return export_x3d.save(self, context, **self.as_keywords(ignore=("check_existing", "filter_glob"))) + + +def menu_func_import(self, context): + self.layout.operator(ImportX3D.bl_idname, text="X3D Extensible 3D (.x3d/.wrl)") + + +def menu_func_export(self, context): + self.layout.operator(ExportX3D.bl_idname, text="X3D Extensible 3D (.x3d)") + + +def register(): + bpy.utils.register_module(__name__) + + bpy.types.INFO_MT_file_import.append(menu_func_import) + bpy.types.INFO_MT_file_export.append(menu_func_export) + + +def unregister(): + bpy.utils.unregister_module(__name__) + + bpy.types.INFO_MT_file_import.remove(menu_func_import) + bpy.types.INFO_MT_file_export.remove(menu_func_export) + +# NOTES +# - blender version is hardcoded + +if __name__ == "__main__": + register() |