Annoying hack to pretend that an operator and its properties are the same, when passi...
authorCampbell Barton <ideasman42@gmail.com>
Fri, 24 Sep 2010 03:48:26 +0000 (03:48 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 24 Sep 2010 03:48:26 +0000 (03:48 +0000)
This means we can do operator drawing without passing self.properties as an argument.

while this check if quite specific, if this gives problems later on we should probably change operators not to try to mix an operator and its properties, it looks nice to a scripter but internally is not easy to manage.

release/scripts/op/io_mesh_ply/__init__.py
release/scripts/op/io_scene_obj/__init__.py
release/scripts/op/object.py
source/blender/python/intern/bpy_rna.c

index 18820dea549062bae9070d2342ebf8530414bc0c..a67afe0cc878b1e18bfe43019738eff9850a0586 100644 (file)
@@ -53,11 +53,11 @@ class ExportPLY(bpy.types.Operator, ExportHelper):
         layout = self.layout
 
         row = layout.row()
-        row.prop(self.properties, "use_modifiers")
-        row.prop(self.properties, "use_normals")
+        row.prop(self, "use_modifiers")
+        row.prop(self, "use_normals")
         row = layout.row()
-        row.prop(self.properties, "use_uv_coords")
-        row.prop(self.properties, "use_colors")
+        row.prop(self, "use_uv_coords")
+        row.prop(self, "use_colors")
 
 
 def menu_func(self, context):
index 63b9e92e166574413f072ea931867e551d3efbc1..d689d84972574ffc299f901c26eaca682f3f877c 100644 (file)
@@ -113,7 +113,6 @@ class ExportOBJ(bpy.types.Operator, ExportHelper):
 
     def execute(self, context):
         import io_scene_obj.export_obj
-        print(self.properties.keys())
         return io_scene_obj.export_obj.save(self, context, **self.properties)
 
 
index fd6235ba78380e7bc051e48d2b1796e3807d1143..61a4478c5e44e904e8b0b70db3b2d41998e1eae5 100644 (file)
@@ -67,10 +67,10 @@ class SelectPattern(bpy.types.Operator):
     def draw(self, context):
         layout = self.layout
 
-        layout.prop(self.properties, "pattern")
+        layout.prop(self, "pattern")
         row = layout.row()
-        row.prop(self.properties, "case_sensitive")
-        row.prop(self.properties, "extend")
+        row.prop(self, "case_sensitive")
+        row.prop(self, "extend")
 
 
 class SelectCamera(bpy.types.Operator):
index 7bb551bd50447efc3b81cdb7917fc710125f5863..a1aa333124919777c86ff5a9187b9a9b294feac5 100644 (file)
@@ -1065,6 +1065,26 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *p
                        StructRNA *ptype= RNA_property_pointer_type(ptr, prop);
                        int flag = RNA_property_flag(prop);
 
+                       /* this is really nasty!, so we can fake the operator having direct properties eg:
+                        * layout.prop(self, "filepath")
+                        * ... which infact should be
+                        * layout.prop(self.properties, "filepath")
+                        * 
+                        * we need to do this trick.
+                        * if the prop is not an operator type and the pyobject is an operator, use its properties in place of its self.
+                        * 
+                        * this is so bad that its almost a good reason to do away with fake 'self.properties -> self' class mixing
+                        * if this causes problems in the future it should be removed.
+                        */
+                       if(     (ptype == &RNA_AnyType) &&
+                               (BPy_StructRNA_Check(value)) &&
+                               (RNA_struct_is_a(((BPy_StructRNA *)value)->ptr.type, &RNA_Operator))
+                       ) {
+                               value= PyObject_GetAttrString(value, "properties");
+                               value_new= value;
+                       }
+
+
                        /* if property is an OperatorProperties pointer and value is a map, forward back to pyrna_pydict_to_props */
                        if (RNA_struct_is_a(ptype, &RNA_OperatorProperties) && PyDict_Check(value)) {
                                PointerRNA opptr = RNA_property_pointer_get(ptr, prop);