bugfix [#24696] Export OBJ - Selection Only toggle button has the wrong default state.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 15 Nov 2010 13:11:40 +0000 (13:11 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 15 Nov 2010 13:11:40 +0000 (13:11 +0000)
Added convenience function to operators, 'as_keywords()', so operator settings can be passed directly to a function as keyword arguments.

The problem in this case was that dictionary access to operator properties was not returning rna-property defaults, so as_keywords() ensures all defaults are set.

release/scripts/modules/bpy_types.py
release/scripts/op/io_anim_bvh/__init__.py
release/scripts/op/io_mesh_ply/__init__.py
release/scripts/op/io_scene_3ds/__init__.py
release/scripts/op/io_scene_fbx/__init__.py
release/scripts/op/io_scene_obj/__init__.py
release/scripts/op/io_scene_x3d/__init__.py
release/scripts/op/io_shape_mdd/__init__.py

index 6c1c86c3eae901dcac08ad127e6beb966fef27b1..31450031c6b4c6c3137d7445d23a6f2835e3932e 100644 (file)
@@ -660,6 +660,12 @@ class Operator(StructRNA, metaclass=OrderedMeta):
             return delattr(properties, attr)
         return super().__delattr__(attr)
 
+    def as_keywords(self, ignore=()):
+        """ Return a copy of the properties as a dictionary.
+        """
+        ignore = ignore + ("rna_type",)
+        return {attr: getattr(self, attr) for attr in self.properties.rna_type.properties.keys() if attr not in ignore}
+
 
 class Macro(StructRNA, metaclass=OrderedMeta):
     # bpy_types is imported before ops is defined
index e7b922e1ceb07ace43b4d6cf1737b165a083b212..de7d135a7b3d233d2a41f09ca91238217143bc12 100644 (file)
@@ -57,13 +57,7 @@ class BvhImporter(bpy.types.Operator, ImportHelper):
 
     def execute(self, context):
         import io_anim_bvh.import_bvh
-        return io_anim_bvh.import_bvh.load(self, context,
-                                           filepath=self.filepath,
-                                           rotate_mode=self.rotate_mode,
-                                           scale=self.scale,
-                                           use_cyclic=self.use_cyclic,
-                                           frame_start=self.frame_start,
-                                           )
+        return io_anim_bvh.import_bvh.load(self, context, **self.as_keywords(ignore=("filter_glob",)))
 
 
 def menu_func(self, context):
index a67afe0cc878b1e18bfe43019738eff9850a0586..93e9e24ddd1791df4aeb39ffac776c5e3904ce9a 100644 (file)
@@ -47,7 +47,7 @@ class ExportPLY(bpy.types.Operator, ExportHelper):
         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.properties)
+        return io_mesh_ply.export_ply.save(self, context, **self.as_keywords(ignore=("check_existing",)))
 
     def draw(self, context):
         layout = self.layout
index 818fb1c4bb208b553ec4f46cba951229678737dc..cdc5ffb09fbc76ce9ab899e7beb7837ce03ccb59 100644 (file)
@@ -44,7 +44,7 @@ class Import3DS(bpy.types.Operator, ImportHelper):
 
     def execute(self, context):
         import io_scene_3ds.import_3ds
-        return io_scene_3ds.import_3ds.load(self, context, **self.properties)
+        return io_scene_3ds.import_3ds.load(self, context, **self.as_keywords(ignore=("filter_glob",)))
 
 
 class Export3DS(bpy.types.Operator, ExportHelper):
@@ -56,7 +56,7 @@ class Export3DS(bpy.types.Operator, ExportHelper):
 
     def execute(self, context):
         import io_scene_3ds.export_3ds
-        return io_scene_3ds.export_3ds.save(self, context, **self.properties)
+        return io_scene_3ds.export_3ds.save(self, context, **self.as_keywords(ignore=("check_existing",)))
 
 
 # Add to a menu
index 75d302153f7fdb104335c4451fc3d2d43415cc48..772e8b4c87886a2632cb85ce8936cdc7b4d658d8 100644 (file)
@@ -52,7 +52,7 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
     EXP_ARMATURE = BoolProperty(name="Armatures", description="Export armature objects", default=True)
     EXP_MESH = BoolProperty(name="Meshes", description="Export mesh objects", default=True)
     EXP_MESH_APPLY_MOD = BoolProperty(name="Modifiers", description="Apply modifiers to mesh objects", default=True)
-    EXP_MESH_HQ_NORMALS = BoolProperty(name="HQ Normals", description="Generate high quality normals", default=True)
+#    EXP_MESH_HQ_NORMALS = BoolProperty(name="HQ Normals", description="Generate high quality normals", default=True)
     EXP_IMAGE_COPY = BoolProperty(name="Copy Image Files", description="Copy image files to the destination path", default=False)
     # armature animation
     ANIM_ENABLE = BoolProperty(name="Enable Animation", description="Export keyframe animation", default=True)
@@ -86,25 +86,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.filepath,
-            GLOBAL_MATRIX=GLOBAL_MATRIX,
-            EXP_OBS_SELECTED=self.EXP_OBS_SELECTED,
-            EXP_MESH=self.EXP_MESH,
-            EXP_MESH_APPLY_MOD=self.EXP_MESH_APPLY_MOD,
-            EXP_ARMATURE=self.EXP_ARMATURE,
-            EXP_LAMP=self.EXP_LAMP,
-            EXP_CAMERA=self.EXP_CAMERA,
-            EXP_EMPTY=self.EXP_EMPTY,
-            EXP_IMAGE_COPY=self.EXP_IMAGE_COPY,
-            ANIM_ENABLE=self.ANIM_ENABLE,
-            ANIM_OPTIMIZE=self.ANIM_OPTIMIZE,
-            ANIM_OPTIMIZE_PRECISSION=self.ANIM_OPTIMIZE_PRECISSION,
-            ANIM_ACTION_ALL=self.ANIM_ACTION_ALL,
-            BATCH_ENABLE=self.BATCH_ENABLE,
-            BATCH_GROUP=self.BATCH_GROUP,
-            BATCH_FILE_PREFIX=self.BATCH_FILE_PREFIX,
-            BATCH_OWN_DIR=self.BATCH_OWN_DIR,
-            )
+        return io_scene_fbx.export_fbx.save(self, context, **self.as_keywords(ignore=("TX_XROT90", "TX_YROT90", "TX_ZROT90", "TX_SCALE", "check_existing")))
 
 
 def menu_func(self, context):
index 4d7da65a7b0e2a05b2b01f956cb33847de62b3be..feeea4c5a716a32cce93598cb2dc2080feb462a9 100644 (file)
@@ -56,22 +56,7 @@ 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.properties)
-        '''
-        load_obj(self.filepath,
-                 context,
-                 self.CLAMP_SIZE,
-                 self.CREATE_FGONS,
-                 self.CREATE_SMOOTH_GROUPS,
-                 self.CREATE_EDGES,
-                 self.SPLIT_OBJECTS,
-                 self.SPLIT_GROUPS,
-                 self.ROTATE_X90,
-                 self.IMAGE_SEARCH,
-                 self.POLYGROUPS)
-        '''
-
-        return {'FINISHED'}
+        return io_scene_obj.import_obj.load(self, context, **self.as_keywords(ignore=("filter_glob",)))
 
 
 class ExportOBJ(bpy.types.Operator, ExportHelper):
@@ -114,7 +99,7 @@ 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.properties)
+        return io_scene_obj.export_obj.save(self, context, **self.as_keywords(ignore=("check_existing",)))
 
 
 def menu_func_import(self, context):
index 4ccd29808bf9c47f7ea8687e296bbf3541280b14..ce9dacd71c8cae6190110bd981414718e3d0374e 100644 (file)
@@ -41,7 +41,7 @@ class ExportX3D(bpy.types.Operator, ExportHelper):
 
     def execute(self, context):
         import io_scene_x3d.export_x3d
-        return io_scene_x3d.export_x3d.save(self, context, **self.properties)
+        return io_scene_x3d.export_x3d.save(self, context, **self.as_keywords(ignore=("check_existing",)))
 
 
 def menu_func(self, context):
index 6453d70f56919445ab5a8e59e44157d026cadcb9..651be3695ef9bd8d13b4941a116dae10516be846 100644 (file)
@@ -55,7 +55,7 @@ class ImportMDD(bpy.types.Operator, ImportHelper):
             self.frame_start = scene.frame_current
         
         import io_shape_mdd.import_mdd
-        return io_shape_mdd.import_mdd.load(self, context, **self.properties)
+        return io_shape_mdd.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,7 +93,7 @@ class ExportMDD(bpy.types.Operator, ExportHelper):
             self.fps = scene.render.fps
 
         import io_shape_mdd.export_mdd
-        return io_shape_mdd.export_mdd.save(self, context, **self.properties)
+        return io_shape_mdd.export_mdd.save(self, context, **self.as_keywords(ignore=("check_existing",)))
 
 
 def menu_func_import(self, context):