From e61c90e4162040f564e154da055995e2ed280fdf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 19 Nov 2009 17:12:08 +0000 Subject: [PATCH] operators were copying the properties from the rna operator into the class instance. however this meant the invoke function could not modify properties for exec to use (unless it called exec directly after) since the popup for eg would re-instance the python class each time. now use the operator properties directly through rna without an automatic copy. now an operator attribute is accessed like this... self.path --> self.properties.path --- release/scripts/io/export_3ds.py | 2 +- release/scripts/io/export_fbx.py | 46 ++--- release/scripts/io/export_mdd.py | 6 +- release/scripts/io/export_obj.py | 36 ++-- release/scripts/io/export_ply.py | 12 +- release/scripts/io/export_x3d.py | 2 +- release/scripts/io/import_anim_bvh.py | 2 +- release/scripts/io/import_scene_3ds.py | 2 +- release/scripts/io/import_scene_obj.py | 22 +-- release/scripts/modules/rna_prop_ui.py | 162 +++++++++++++----- release/scripts/op/add_mesh_torus.py | 8 +- release/scripts/op/uvcalc_smart_project.py | 2 +- release/scripts/op/vertexpaint_dirt.py | 4 +- release/scripts/op/wm.py | 63 ++++--- release/scripts/templates/operator.py | 2 +- release/scripts/ui/space_console.py | 2 +- release/scripts/ui/space_userpref.py | 6 +- release/scripts/ui/space_view3d.py | 6 +- .../blender/python/intern/bpy_operator_wrap.c | 19 -- 19 files changed, 230 insertions(+), 174 deletions(-) diff --git a/release/scripts/io/export_3ds.py b/release/scripts/io/export_3ds.py index a96abb50215..0d5827f6f18 100644 --- a/release/scripts/io/export_3ds.py +++ b/release/scripts/io/export_3ds.py @@ -1123,7 +1123,7 @@ class Export3DS(bpy.types.Operator): def execute(self, context): - save_3ds(self.path, context) + save_3ds(self.properties.path, context) return ('FINISHED',) def invoke(self, context, event): diff --git a/release/scripts/io/export_fbx.py b/release/scripts/io/export_fbx.py index 8b7501bea4d..b266d74fb57 100644 --- a/release/scripts/io/export_fbx.py +++ b/release/scripts/io/export_fbx.py @@ -3393,36 +3393,36 @@ class ExportFBX(bpy.types.Operator): return context.active_object != None def execute(self, context): - if not self.path: + if not self.properties.path: raise Exception("path not set") GLOBAL_MATRIX = mtx4_identity - GLOBAL_MATRIX[0][0] = GLOBAL_MATRIX[1][1] = GLOBAL_MATRIX[2][2] = self._SCALE - if self._XROT90: GLOBAL_MATRIX = GLOBAL_MATRIX * mtx4_x90n - if self._YROT90: GLOBAL_MATRIX = GLOBAL_MATRIX * mtx4_y90n - if self._ZROT90: GLOBAL_MATRIX = GLOBAL_MATRIX * mtx4_z90n + GLOBAL_MATRIX[0][0] = GLOBAL_MATRIX[1][1] = GLOBAL_MATRIX[2][2] = self.properties._SCALE + if self.properties._XROT90: GLOBAL_MATRIX = GLOBAL_MATRIX * mtx4_x90n + if self.properties._YROT90: GLOBAL_MATRIX = GLOBAL_MATRIX * mtx4_y90n + if self.properties._ZROT90: GLOBAL_MATRIX = GLOBAL_MATRIX * mtx4_z90n - write(self.path, + write(self.properties.path, None, # XXX context, - self.EXP_OBS_SELECTED, - self.EXP_MESH, - self.EXP_MESH_APPLY_MOD, -# self.EXP_MESH_HQ_NORMALS, - self.EXP_ARMATURE, - self.EXP_LAMP, - self.EXP_CAMERA, - self.EXP_EMPTY, - self.EXP_IMAGE_COPY, + self.properties.EXP_OBS_SELECTED, + self.properties.EXP_MESH, + self.properties.EXP_MESH_APPLY_MOD, +# self.properties.EXP_MESH_HQ_NORMALS, + self.properties.EXP_ARMATURE, + self.properties.EXP_LAMP, + self.properties.EXP_CAMERA, + self.properties.EXP_EMPTY, + self.properties.EXP_IMAGE_COPY, GLOBAL_MATRIX, - self.ANIM_ENABLE, - self.ANIM_OPTIMIZE, - self.ANIM_OPTIMIZE_PRECISSION, - self.ANIM_ACTION_ALL, - self.BATCH_ENABLE, - self.BATCH_GROUP, - self.BATCH_FILE_PREFIX, - self.BATCH_OWN_DIR) + self.properties.ANIM_ENABLE, + self.properties.ANIM_OPTIMIZE, + self.properties.ANIM_OPTIMIZE_PRECISSION, + self.properties.ANIM_ACTION_ALL, + self.properties.BATCH_ENABLE, + self.properties.BATCH_GROUP, + self.properties.BATCH_FILE_PREFIX, + self.properties.BATCH_OWN_DIR) return ('FINISHED',) diff --git a/release/scripts/io/export_mdd.py b/release/scripts/io/export_mdd.py index 729b23e4202..7d08b4f9d7a 100644 --- a/release/scripts/io/export_mdd.py +++ b/release/scripts/io/export_mdd.py @@ -173,10 +173,10 @@ class ExportMDD(bpy.types.Operator): return (ob and ob.type=='MESH') def execute(self, context): - if not self.path: + if not self.properties.path: raise Exception("filename not set") - write(self.path, context.scene, context.active_object, - self.start_frame, self.end_frame, self.fps ) + write(self.properties.path, context.scene, context.active_object, + self.properties.start_frame, self.properties.end_frame, self.properties.fps ) return ('FINISHED',) def invoke(self, context, event): diff --git a/release/scripts/io/export_obj.py b/release/scripts/io/export_obj.py index 2c77cbd702a..34e05c44846 100644 --- a/release/scripts/io/export_obj.py +++ b/release/scripts/io/export_obj.py @@ -972,24 +972,24 @@ class ExportOBJ(bpy.types.Operator): def execute(self, context): - do_export(self.path, context, - EXPORT_TRI=self.use_triangles, - EXPORT_EDGES=self.use_edges, - EXPORT_NORMALS=self.use_normals, - EXPORT_NORMALS_HQ=self.use_hq_normals, - EXPORT_UV=self.use_uvs, - EXPORT_MTL=self.use_materials, - EXPORT_COPY_IMAGES=self.copy_images, - EXPORT_APPLY_MODIFIERS=self.use_modifiers, - EXPORT_ROTX90=self.use_rotate90, - EXPORT_BLEN_OBS=self.use_blen_objects, - EXPORT_GROUP_BY_OB=self.group_by_object, - EXPORT_GROUP_BY_MAT=self.group_by_material, - EXPORT_KEEP_VERT_ORDER=self.keep_vertex_order, - EXPORT_POLYGROUPS=self.use_vertex_groups, - EXPORT_CURVE_AS_NURBS=self.use_nurbs, - EXPORT_SEL_ONLY=self.use_selection, - EXPORT_ALL_SCENES=self.use_all_scenes) + do_export(self.properties.path, context, + EXPORT_TRI=self.properties.use_triangles, + EXPORT_EDGES=self.properties.use_edges, + EXPORT_NORMALS=self.properties.use_normals, + EXPORT_NORMALS_HQ=self.properties.use_hq_normals, + EXPORT_UV=self.properties.use_uvs, + EXPORT_MTL=self.properties.use_materials, + EXPORT_COPY_IMAGES=self.properties.copy_images, + EXPORT_APPLY_MODIFIERS=self.properties.use_modifiers, + EXPORT_ROTX90=self.properties.use_rotate90, + EXPORT_BLEN_OBS=self.properties.use_blen_objects, + EXPORT_GROUP_BY_OB=self.properties.group_by_object, + EXPORT_GROUP_BY_MAT=self.properties.group_by_material, + EXPORT_KEEP_VERT_ORDER=self.properties.keep_vertex_order, + EXPORT_POLYGROUPS=self.properties.use_vertex_groups, + EXPORT_CURVE_AS_NURBS=self.properties.use_nurbs, + EXPORT_SEL_ONLY=self.properties.use_selection, + EXPORT_ALL_SCENES=self.properties.use_all_scenes) return ('FINISHED',) diff --git a/release/scripts/io/export_ply.py b/release/scripts/io/export_ply.py index 99fa3233278..e97ca2155f0 100644 --- a/release/scripts/io/export_ply.py +++ b/release/scripts/io/export_ply.py @@ -274,14 +274,14 @@ class ExportPLY(bpy.types.Operator): def execute(self, context): # print("Selected: " + context.active_object.name) - if not self.path: + if not self.properties.path: raise Exception("filename not set") - write(self.path, context.scene, context.active_object,\ - EXPORT_APPLY_MODIFIERS = self.use_modifiers, - EXPORT_NORMALS = self.use_normals, - EXPORT_UV = self.use_uvs, - EXPORT_COLORS = self.use_colors, + write(self.properties.path, context.scene, context.active_object,\ + EXPORT_APPLY_MODIFIERS = self.properties.use_modifiers, + EXPORT_NORMALS = self.properties.use_normals, + EXPORT_UV = self.properties.use_uvs, + EXPORT_COLORS = self.properties.use_colors, ) return ('FINISHED',) diff --git a/release/scripts/io/export_x3d.py b/release/scripts/io/export_x3d.py index c8c5f71f6ff..1fb43930208 100644 --- a/release/scripts/io/export_x3d.py +++ b/release/scripts/io/export_x3d.py @@ -1230,7 +1230,7 @@ class ExportX3D(bpy.types.Operator): def execute(self, context): - x3d_export(self.path, context, self.apply_modifiers, self.triangulate, self.compress) + x3d_export(self.properties.path, context, self.properties.apply_modifiers, self.properties.triangulate, self.properties.compress) return ('FINISHED',) def invoke(self, context, event): diff --git a/release/scripts/io/import_anim_bvh.py b/release/scripts/io/import_anim_bvh.py index 8185785d1b2..364a16b00ea 100644 --- a/release/scripts/io/import_anim_bvh.py +++ b/release/scripts/io/import_anim_bvh.py @@ -863,7 +863,7 @@ class BvhImporter(bpy.types.Operator): def execute(self, context): # print("Selected: " + context.active_object.name) - read_bvh(context, self.path) + read_bvh(context, self.properties.path) return ('FINISHED',) diff --git a/release/scripts/io/import_scene_3ds.py b/release/scripts/io/import_scene_3ds.py index cd351ccb99e..35cd4028a4b 100644 --- a/release/scripts/io/import_scene_3ds.py +++ b/release/scripts/io/import_scene_3ds.py @@ -1156,7 +1156,7 @@ class IMPORT_OT_autodesk_3ds(bpy.types.Operator): # apply_matrix = BoolProperty(name="Transform Fix", description="Workaround for object transformations importing incorrectly", default=False), def execute(self, context): - load_3ds(self.path, context, 0.0, False, False) + load_3ds(self.properties.path, context, 0.0, False, False) return ('FINISHED',) def invoke(self, context, event): diff --git a/release/scripts/io/import_scene_obj.py b/release/scripts/io/import_scene_obj.py index d1b29a3024d..6e67c14d37a 100644 --- a/release/scripts/io/import_scene_obj.py +++ b/release/scripts/io/import_scene_obj.py @@ -1601,18 +1601,18 @@ class IMPORT_OT_obj(bpy.types.Operator): def execute(self, context): # print("Selected: " + context.active_object.name) - load_obj(self.path, + load_obj(self.properties.path, context, - self.CLAMP_SIZE, - self.CREATE_FGONS, - self.CREATE_SMOOTH_GROUPS, - self.CREATE_EDGES, - self.SPLIT_OBJECTS, - self.SPLIT_GROUPS, - self.SPLIT_MATERIALS, - self.ROTATE_X90, - self.IMAGE_SEARCH, - self.POLYGROUPS) + self.properties.CLAMP_SIZE, + self.properties.CREATE_FGONS, + self.properties.CREATE_SMOOTH_GROUPS, + self.properties.CREATE_EDGES, + self.properties.SPLIT_OBJECTS, + self.properties.SPLIT_GROUPS, + self.properties.SPLIT_MATERIALS, + self.properties.ROTATE_X90, + self.properties.IMAGE_SEARCH, + self.properties.POLYGROUPS) return ('FINISHED',) diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py index 7f741e46bd0..e4d3de2cef0 100644 --- a/release/scripts/modules/rna_prop_ui.py +++ b/release/scripts/modules/rna_prop_ui.py @@ -26,6 +26,7 @@ EVIL_PROP_VALUE = EVIL_PROP + '_value' EVIL_PROP_PROP = EVIL_PROP + '_prop' EVIL_PROP_PROP_ORIG = EVIL_PROP + '_prop_orig' + # nasty!, use a scene property to store the active edit item def evil_prop_init(): Scene = bpy.types.Scene @@ -35,6 +36,42 @@ def evil_prop_init(): Scene.StringProperty(attr=EVIL_PROP_PROP) Scene.StringProperty(attr=EVIL_PROP_PROP_ORIG) +def rna_idprop_ui_get(item, create=True): + try: + return item['_RNA_UI'] + except: + if create: + item['_RNA_UI'] = {} + return item['_RNA_UI'] + else: + return None + + +def rna_idprop_ui_prop_get(item, prop, create=True): + + rna_ui = rna_idprop_ui_get(item, create) + + if rna_ui == None: + return None + + try: + return rna_ui[prop] + except: + rna_ui[prop] = {} + return rna_ui[prop] + + +def rna_idprop_ui_prop_clear(item, prop): + rna_ui = rna_idprop_ui_get(item, False) + + if rna_ui == None: + return + + try: + del rna_ui[prop] + except: + pass + def draw(layout, context, context_member, use_edit = True): @@ -70,7 +107,7 @@ def draw(layout, context, context_member, use_edit = True): del row for key, val in items: - + print("KEY - " + key) if key == '_RNA_UI': continue @@ -86,6 +123,7 @@ def draw(layout, context, context_member, use_edit = True): box = row.box() + ''' if use_edit and key == global_prop_orig and context_member == global_path: split = box.split(percentage=0.75) @@ -94,10 +132,12 @@ def draw(layout, context, context_member, use_edit = True): row.itemR(scene, EVIL_PROP_VALUE) row = split.column() - prop = row.itemO("wm.properties_edit_end", properties=True, text="done") + prop = row.itemO("wm.properties_edit", properties=True, text="done") assign_props(prop, val_draw, key) else: + ''' + if 1: if use_edit: split = box.split(percentage=0.75) row = split.row() @@ -114,7 +154,7 @@ def draw(layout, context, context_member, use_edit = True): if use_edit: row = split.row(align=True) - prop = row.itemO("wm.properties_edit_begin", properties=True, text="edit") + prop = row.itemO("wm.properties_edit", properties=True, text="edit") assign_props(prop, val_draw, key) prop = row.itemO("wm.properties_remove", properties=True, text="", icon='ICON_ZOOMOUT') @@ -125,7 +165,7 @@ from bpy.props import * rna_path = StringProperty(name="Property Edit", - description="Property path edit", maxlen=1024, default="") + description="Property path edit", maxlen=1024, default="", hidden=True) rna_value = StringProperty(name="Property Value", description="Property value edit", maxlen=1024, default="") @@ -133,69 +173,104 @@ rna_value = StringProperty(name="Property Value", rna_property = StringProperty(name="Property Name", description="Property name edit", maxlen=1024, default="") -class WM_OT_properties_edit_begin(bpy.types.Operator): +rna_min = FloatProperty(name="Min", default=0.0) +rna_min = FloatProperty(name="Max", default=1.0) + +class WM_OT_properties_edit(bpy.types.Operator): '''Internal use (edit a property path)''' - bl_idname = "wm.properties_edit_begin" - bl_label = "Edit Property" + bl_idname = "wm.properties_edit" + bl_label = "Edit Property!" path = rna_path value = rna_value property = rna_property + + min = FloatProperty(name="Min", default=0.0) + max = FloatProperty(name="Max", default=1.0) + description = StringProperty(name="Tip", default="") + + # the class instance is not persistant, need to store in the class + # not ideal but changes as the op runs. + _last_prop = [''] def execute(self, context): - scene = context.scene - - setattr(scene, EVIL_PROP_PATH, self.path) - setattr(scene, EVIL_PROP_VALUE, self.value) - setattr(scene, EVIL_PROP_PROP, self.property) - setattr(scene, EVIL_PROP_PROP_ORIG, self.property) - - return ('FINISHED',) + global_path = self.properties.path + global_value = self.properties.value + global_prop = self.properties.property + global_prop_old = self._last_prop[0] - -class WM_OT_properties_edit_end(bpy.types.Operator): - '''Internal use (edit a property path)''' - bl_idname = "wm.properties_edit_end" - bl_label = "Edit Property" - - path = rna_path - value = rna_value - property = rna_property - - def execute(self, context): - - scene = context.scene - global_path = getattr(scene, EVIL_PROP_PATH) - global_value = getattr(scene, EVIL_PROP_VALUE) - global_prop = getattr(scene, EVIL_PROP_PROP) - - setattr(scene, EVIL_PROP_PATH, "") - setattr(scene, EVIL_PROP_VALUE, "") - setattr(scene, EVIL_PROP_PROP, "") - setattr(scene, EVIL_PROP_PROP_ORIG, "") - try: value = eval(global_value) except: value = global_value if type(value) == str: - value = '"' + value + '"' - + value = '"' + value + '"' # First remove - exec_str = "del context.%s['%s']" % (global_path, self.property) + item = eval("context.%s" % global_path) + + rna_idprop_ui_prop_clear(item, global_prop_old) + exec_str = "del item['%s']" % global_prop_old # print(exec_str) exec(exec_str) # Reassign - exec_str = "context.%s['%s'] = %s" % (global_path, global_prop, value) + exec_str = "item['%s'] = %s" % (global_prop, value) # print(exec_str) exec(exec_str) + prop_type = type(item[global_prop]) + + prop_ui = rna_idprop_ui_prop_get(item, global_prop) + + if prop_type in (float, int): + + prop_ui['soft_min'] = prop_ui['min'] = prop_type(self.properties.min) + prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.properties.max) + return ('FINISHED',) + def invoke(self, context, event): + + self._last_prop[:] = [self.properties.property] + + item = eval("context.%s" % self.properties.path) + + # setup defaults + prop_ui = rna_idprop_ui_prop_get(item, self.properties.property, False) # dont create + if prop_ui: + self.properties.min = prop_ui.get("min", -1000000000) + self.properties.min = prop_ui.get("max", 1000000000) + self.properties.description = prop_ui.get("description", "") + + if 0: + _message= "PyConsole, press Ctrl+D to unlock the BGE" + import sys + + # evaluate commands in current namespace + frame= sys._getframe() + namespace = frame.f_globals.copy() + namespace.update(frame.f_locals) + + import code + + # Autocomp in python, not as comprehensive as IPython + import rlcompleter + + try: # ick, some pythons dont have this + import readline + readline.parse_and_bind("tab: complete") + except: + pass + + code.interact(banner=_message, local=namespace) + + wm = context.manager + wm.invoke_props_popup(self, event) + return ('RUNNING_MODAL',) + class WM_OT_properties_add(bpy.types.Operator): '''Internal use (edit a property path)''' @@ -231,6 +306,7 @@ class WM_OT_properties_remove(bpy.types.Operator): property = rna_property def execute(self, context): - item = eval("context.%s" % self.path) - del item[self.property] + item = eval("context.%s" % self.properties.path) + del item[self.properties.property] return ('FINISHED',) + diff --git a/release/scripts/op/add_mesh_torus.py b/release/scripts/op/add_mesh_torus.py index ddc4f0b9770..2321c0bbeab 100644 --- a/release/scripts/op/add_mesh_torus.py +++ b/release/scripts/op/add_mesh_torus.py @@ -96,10 +96,10 @@ class AddTorus(bpy.types.Operator): def execute(self, context): - verts_loc, faces = add_torus(self.major_radius, - self.minor_radius, - self.major_segments, - self.minor_segments) + verts_loc, faces = add_torus(self.properties.major_radius, + self.properties.minor_radius, + self.properties.major_segments, + self.properties.minor_segments) mesh = bpy.data.add_mesh("Torus") diff --git a/release/scripts/op/uvcalc_smart_project.py b/release/scripts/op/uvcalc_smart_project.py index 11202329a3d..23357bd1572 100644 --- a/release/scripts/op/uvcalc_smart_project.py +++ b/release/scripts/op/uvcalc_smart_project.py @@ -1128,7 +1128,7 @@ class SmartProject(bpy.types.Operator): return context.active_object != None def execute(self, context): - main(context, self.island_margin, self.angle_limit) + main(context, self.properties.island_margin, self.properties.angle_limit) return ('FINISHED',) bpy.ops.add(SmartProject) diff --git a/release/scripts/op/vertexpaint_dirt.py b/release/scripts/op/vertexpaint_dirt.py index 04398dfa8ce..bd052e909b6 100644 --- a/release/scripts/op/vertexpaint_dirt.py +++ b/release/scripts/op/vertexpaint_dirt.py @@ -166,7 +166,7 @@ class VertexPaintDirt(bpy.types.Operator): t = time.time() - applyVertexDirt(me, self.blur_iterations, self.blur_strength, math.radians(self.dirt_angle), math.radians(self.clean_angle), self.dirt_only) + applyVertexDirt(me, self.properties.blur_iterations, self.properties.blur_strength, math.radians(self.properties.dirt_angle), math.radians(self.properties.clean_angle), self.properties.dirt_only) print('Dirt calculated in %.6f' % (time.time()-t)) @@ -175,4 +175,4 @@ class VertexPaintDirt(bpy.types.Operator): bpy.ops.add(VertexPaintDirt) if __name__ == "__main__": - bpy.ops.mesh.vertex_paint_dirt() + bpy.ops.mesh.vertex_paint_dirt() \ No newline at end of file diff --git a/release/scripts/op/wm.py b/release/scripts/op/wm.py index 5e0894d9907..1f660dbeb35 100644 --- a/release/scripts/op/wm.py +++ b/release/scripts/op/wm.py @@ -60,9 +60,9 @@ def context_path_validate(context, path): def execute_context_assign(self, context): - if context_path_validate(context, self.path) == NullPathMember: + if context_path_validate(context, self.properties.path) == NullPathMember: return ('PASS_THROUGH',) - exec("context.%s=self.value" % self.path) + exec("context.%s=self.properties.value" % self.properties.path) return ('FINISHED',) @@ -134,10 +134,10 @@ class WM_OT_context_toggle(bpy.types.Operator): def execute(self, context): - if context_path_validate(context, self.path) == NullPathMember: + if context_path_validate(context, self.properties.path) == NullPathMember: return ('PASS_THROUGH',) - exec("context.%s=not (context.%s)" % (self.path, self.path)) + exec("context.%s=not (context.%s)" % (self.properties.path, self.properties.path)) return ('FINISHED',) @@ -155,11 +155,11 @@ class WM_OT_context_toggle_enum(bpy.types.Operator): def execute(self, context): - if context_path_validate(context, self.path) == NullPathMember: + if context_path_validate(context, self.properties.path) == NullPathMember: return ('PASS_THROUGH',) exec("context.%s = ['%s', '%s'][context.%s!='%s']" % \ - (self.path, self.value_1, self.value_2, self.path, self.value_2)) + (self.properties.path, self.properties.value_1, self.properties.value_2, self.properties.path, self.properties.value_2)) return ('FINISHED',) @@ -174,23 +174,23 @@ class WM_OT_context_cycle_int(bpy.types.Operator): def execute(self, context): - value = context_path_validate(context, self.path) + value = context_path_validate(context, self.properties.path) if value == NullPathMember: return ('PASS_THROUGH',) - self.value = value - if self.reverse: - self.value -= 1 + self.properties.value = value + if self.properties.reverse: + self.properties.value -= 1 else: - self.value += 1 + self.properties.value += 1 execute_context_assign(self, context) - if self.value != eval("context.%s" % self.path): + if self.properties.value != eval("context.%s" % self.properties.path): # relies on rna clamping int's out of the range - if self.reverse: - self.value = (1 << 32) + if self.properties.reverse: + self.properties.value = (1 << 32) else: - self.value = - (1 << 32) + self.properties.value = - (1 << 32) execute_context_assign(self, context) return ('FINISHED',) @@ -206,14 +206,14 @@ class WM_OT_context_cycle_enum(bpy.types.Operator): def execute(self, context): - value = context_path_validate(context, self.path) + value = context_path_validate(context, self.properties.path) if value == NullPathMember: return ('PASS_THROUGH',) orig_value = value # Have to get rna enum values - rna_struct_str, rna_prop_str = self.path.rsplit('.', 1) + rna_struct_str, rna_prop_str = self.properties.path.rsplit('.', 1) i = rna_prop_str.find('[') # just incse we get "context.foo.bar[0]" @@ -231,7 +231,7 @@ class WM_OT_context_cycle_enum(bpy.types.Operator): orig_index = enums.index(orig_value) # Have the info we need, advance to the next item - if self.reverse: + if self.properties.reverse: if orig_index == 0: advance_enum = enums[-1] else: @@ -243,7 +243,7 @@ class WM_OT_context_cycle_enum(bpy.types.Operator): advance_enum = enums[orig_index + 1] # set the new value - exec("context.%s=advance_enum" % self.path) + exec("context.%s=advance_enum" % self.properties.path) return ('FINISHED',) doc_id = StringProperty(name="Doc ID", @@ -270,7 +270,7 @@ class WM_OT_doc_view(bpy.types.Operator): return '.'.join([class_obj.identifier for class_obj in ls]) def execute(self, context): - id_split = self.doc_id.split('.') + id_split = self.properties.doc_id.split('.') if len(id_split) == 1: # rna, class url = '%s/bpy.types.%s-class.html' % (self._prefix, id_split[0]) elif len(id_split) == 2: # rna, class.prop @@ -316,9 +316,9 @@ class WM_OT_doc_edit(bpy.types.Operator): def execute(self, context): - class_name, class_prop = self.doc_id.split('.') + class_name, class_prop = self.properties.doc_id.split('.') - if not self.doc_new: + if not self.properties.doc_new: return ('RUNNING_MODAL',) # check if this is an operator @@ -331,25 +331,25 @@ class WM_OT_doc_edit(bpy.types.Operator): if op_class: rna = op_class.bl_rna doc_orig = rna.description - if doc_orig == self.doc_new: + if doc_orig == self.properties.doc_new: return ('RUNNING_MODAL',) - print("op - old:'%s' -> new:'%s'" % (doc_orig, self.doc_new)) - upload["title"] = 'OPERATOR %s:%s' % (self.doc_id, doc_orig) - upload["description"] = self.doc_new + print("op - old:'%s' -> new:'%s'" % (doc_orig, self.properties.doc_new)) + upload["title"] = 'OPERATOR %s:%s' % (self.properties.doc_id, doc_orig) + upload["description"] = self.properties.doc_new self._send_xmlrpc(upload) else: rna = getattr(bpy.types, class_name).bl_rna doc_orig = rna.properties[class_prop].description - if doc_orig == self.doc_new: + if doc_orig == self.properties.doc_new: return ('RUNNING_MODAL',) - print("rna - old:'%s' -> new:'%s'" % (doc_orig, self.doc_new)) - upload["title"] = 'RNA %s:%s' % (self.doc_id, doc_orig) + print("rna - old:'%s' -> new:'%s'" % (doc_orig, self.properties.doc_new)) + upload["title"] = 'RNA %s:%s' % (self.properties.doc_id, doc_orig) - upload["description"] = self.doc_new + upload["description"] = self.properties.doc_new self._send_xmlrpc(upload) @@ -410,7 +410,6 @@ bpy.ops.add(WM_OT_reload_scripts) # experemental! import rna_prop_ui -bpy.ops.add(rna_prop_ui.WM_OT_properties_edit_begin) -bpy.ops.add(rna_prop_ui.WM_OT_properties_edit_end) +bpy.ops.add(rna_prop_ui.WM_OT_properties_edit) bpy.ops.add(rna_prop_ui.WM_OT_properties_add) bpy.ops.add(rna_prop_ui.WM_OT_properties_remove) diff --git a/release/scripts/templates/operator.py b/release/scripts/templates/operator.py index 60d7eeeabf9..dc46b66c96f 100644 --- a/release/scripts/templates/operator.py +++ b/release/scripts/templates/operator.py @@ -28,7 +28,7 @@ class ExportSomeData(bpy.types.Operator): #if not self.is_property_set("path"): # raise Exception("filename not set") - write_some_data(self.path, context, self.use_setting) + write_some_data(self.properties.path, context, self.properties.use_setting) return ('FINISHED',) diff --git a/release/scripts/ui/space_console.py b/release/scripts/ui/space_console.py index 2404b3b71c0..8aa4df7b16a 100644 --- a/release/scripts/ui/space_console.py +++ b/release/scripts/ui/space_console.py @@ -180,7 +180,7 @@ class ConsoleLanguage(bpy.types.Operator): sc = context.space_data # defailt to python - sc.language = self.language + sc.language = self.properties.language bpy.ops.console.banner() diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py index d6982db4fd0..28eb8dc06c0 100644 --- a/release/scripts/ui/space_userpref.py +++ b/release/scripts/ui/space_userpref.py @@ -1309,10 +1309,10 @@ class WM_OT_keyconfig_export(bpy.types.Operator): return result def execute(self, context): - if not self.path: + if not self.properties.path: raise Exception("File path not set.") - f = open(self.path, "w") + f = open(self.properties.path, "w") if not f: raise Exception("Could not open file.") @@ -1392,7 +1392,7 @@ class WM_OT_keymap_restore(bpy.types.Operator): def execute(self, context): wm = context.manager - if self.all: + if self.properties.all: for km in wm.default_keyconfig.keymaps: km.restore_to_default() else: diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 817bd5fa43f..15663b615a0 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -1671,15 +1671,15 @@ class OBJECT_OT_select_pattern(bpy.types.Operator): import fnmatch - if self.case_sensitive: + if self.properties.case_sensitive: pattern_match = fnmatch.fnmatchcase else: pattern_match = lambda a, b: fnmatch.fnmatchcase(a.upper(), b.upper()) for ob in context.visible_objects: - if pattern_match(ob.name, self.pattern): + if pattern_match(ob.name, self.properties.pattern): ob.selected = True - elif not self.extend: + elif not self.properties.extend: ob.selected = False return ('FINISHED',) diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index 5f3ddf02d7b..1aa56befe0e 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -106,24 +106,6 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperatorType *ot, wmOperat Py_DECREF(args); if (py_class_instance) { /* Initializing the class worked, now run its invoke function */ - PyObject *class_dict= PyObject_GetAttrString(py_class_instance, "__dict__"); - - /* Assign instance attributes from operator properties */ - if(op) { - const char *arg_name; - - RNA_STRUCT_BEGIN(op->ptr, prop) { - arg_name= RNA_property_identifier(prop); - - if (strcmp(arg_name, "rna_type")==0) continue; - - item = pyrna_prop_to_py(op->ptr, prop); - PyDict_SetItemString(class_dict, arg_name, item); - Py_DECREF(item); - } - RNA_STRUCT_END; - } - RNA_pointer_create(NULL, &RNA_Context, C, &ptr_context); if (mode==PYOP_INVOKE) { @@ -154,7 +136,6 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperatorType *ot, wmOperat Py_DECREF(args); Py_DECREF(item); - Py_DECREF(class_dict); } else { PyErr_Print();