Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-03-12 10:57:38 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-03-12 10:57:38 +0400
commit41c80357961d079bad12713b41b759d0a7baa0b5 (patch)
treedac6a454ebc092165a5fa25e8ce92aad9065f58c
parent25a6ba31f41e405a9279c6fd24f9c51d7d2a453c (diff)
add the ability to export the selection
-rw-r--r--io_mesh_vrml2/__init__.py15
-rw-r--r--io_mesh_vrml2/export_vrml2.py25
2 files changed, 28 insertions, 12 deletions
diff --git a/io_mesh_vrml2/__init__.py b/io_mesh_vrml2/__init__.py
index 50ac86e6..802fb7a7 100644
--- a/io_mesh_vrml2/__init__.py
+++ b/io_mesh_vrml2/__init__.py
@@ -51,6 +51,12 @@ class ExportVRML(bpy.types.Operator, ExportHelper):
filename_ext = ".wrl"
filter_glob = StringProperty(default="*.wrl", options={'HIDDEN'})
+ use_selection = BoolProperty(
+ name="Selection Only",
+ description="Export selected objects only",
+ default=False,
+ )
+
use_mesh_modifiers = BoolProperty(
name="Apply Modifiers",
description="Apply Modifiers to the exported mesh",
@@ -91,17 +97,16 @@ class ExportVRML(bpy.types.Operator, ExportHelper):
def draw(self, context):
layout = self.layout
- row = layout.row()
- row.prop(self, "use_mesh_modifiers")
+ layout.prop(self, "use_selection")
+ layout.prop(self, "use_mesh_modifiers")
+
row = layout.row()
row.prop(self, "use_uv")
row.prop(self, "use_color")
row = layout.row()
row.active = self.use_color
row.prop(self, "color_type")
- row = layout.row()
- row.prop(self, "path_mode")
-
+ layout.prop(self, "path_mode")
def menu_func_export(self, context):
diff --git a/io_mesh_vrml2/export_vrml2.py b/io_mesh_vrml2/export_vrml2.py
index 0cea9969..a3370a3a 100644
--- a/io_mesh_vrml2/export_vrml2.py
+++ b/io_mesh_vrml2/export_vrml2.py
@@ -39,7 +39,7 @@ def save_bmesh(fw, bm,
filepath_full = bpy.path.abspath(filepath, library=uv_image.library)
filepath_ref = bpy_extras.io_utils.path_reference(filepath_full, base_src, base_dst, path_mode, "textures", copy_set, uv_image.library)
filepath_base = os.path.basename(filepath_full)
-
+
images = [
filepath_ref,
filepath_base,
@@ -90,7 +90,7 @@ def save_bmesh(fw, bm,
except:
l = None
fw(c_none if l is None else ("%.2f %.2f %.2f " % l[color_layer][:]))
-
+
del v
fw(']\n') # end 'color[]'
fw('\t\t}\n') # end 'Color'
@@ -232,12 +232,15 @@ def save_object(fw, scene, obj,
def save(operator,
context,
filepath="",
+ use_selection=False,
use_mesh_modifiers=True,
use_color=True,
color_type='MATERIAL',
use_uv=True,
path_mode='AUTO'):
+ scene = context.scene
+
# store files to copy
copy_set = set()
@@ -246,11 +249,19 @@ def save(operator,
fw('#VRML V2.0 utf8\n')
fw('#modeled using blender3d http://blender.org\n')
- save_object(fw, context.scene, context.object,
- use_mesh_modifiers,
- use_color, color_type,
- use_uv,
- path_mode, copy_set)
+ if use_selection:
+ objects = context.selected_objects
+ else:
+ objects = scene.objects
+
+ for obj in objects:
+ if obj.type == 'MESH':
+ fw("\n# %r\n" % obj.name)
+ save_object(fw, scene, obj,
+ use_mesh_modifiers,
+ use_color, color_type,
+ use_uv,
+ path_mode, copy_set)
file.close()