From 79c899da0040c7e058a30760f0b5178f3be672be Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 20 Jan 2011 09:04:36 +0000 Subject: add 3ds export option, use_selection, also fix for exporting curves with no geometry data. --- io_scene_3ds/__init__.py | 2 ++ io_scene_3ds/export_3ds.py | 27 +++++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) (limited to 'io_scene_3ds') diff --git a/io_scene_3ds/__init__.py b/io_scene_3ds/__init__.py index 8e701abe..54840921 100644 --- a/io_scene_3ds/__init__.py +++ b/io_scene_3ds/__init__.py @@ -69,6 +69,8 @@ class Export3DS(bpy.types.Operator, ExportHelper): filename_ext = ".3ds" filter_glob = StringProperty(default="*.3ds", options={'HIDDEN'}) + use_selection = BoolProperty(name="Selection Only", description="Export selected objects only", default=False) + def execute(self, context): from . import export_3ds return export_3ds.save(self, context, **self.as_keywords(ignore=("check_existing", "filter_glob"))) diff --git a/io_scene_3ds/export_3ds.py b/io_scene_3ds/export_3ds.py index b4fb7deb..24013243 100644 --- a/io_scene_3ds/export_3ds.py +++ b/io_scene_3ds/export_3ds.py @@ -859,13 +859,16 @@ def make_kf_obj_node(obj, name_to_id): """ -def save(operator, context, filepath=""): +def save(operator, context, filepath="", + use_selection=True, + ): + import bpy import time from io_utils import create_derived_objects, free_derived_objects - + '''Save the Blender scene to a 3ds file.''' - + # Time the export time1 = time.clock() # Blender.Window.WaitCursor(1) @@ -900,9 +903,14 @@ def save(operator, context, filepath=""): materialDict = {} mesh_objects = [] scene = context.scene - for ob in [ob for ob in scene.objects if ob.is_visible(scene)]: -# for ob in sce.objects.context: + + if use_selection: + objects = (ob for ob in scene.objects if ob.is_visible(scene) and ob.select) + else: + objects = (ob for ob in scene.objects if ob.is_visible(scene)) + + for ob in objects: # get derived objects free, derived = create_derived_objects(scene, ob) @@ -915,8 +923,11 @@ def save(operator, context, filepath=""): if ob.type not in ('MESH', 'CURVE', 'SURFACE', 'FONT', 'META'): continue - data = ob_derived.create_mesh(scene, True, 'PREVIEW') -# data = getMeshFromObject(ob_derived, None, True, False, sce) + try: + data = ob_derived.create_mesh(scene, True, 'PREVIEW') + except: + data = None + if data: data.transform(mat) # data.transform(mat, recalc_normals=False) @@ -1040,5 +1051,5 @@ def save(operator, context, filepath=""): # Debugging only: dump the chunk hierarchy: #primary.dump() - + return {'FINISHED'} -- cgit v1.2.3