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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'release/scripts/startup/bl_operators/wm.py')
-rw-r--r--release/scripts/startup/bl_operators/wm.py455
1 files changed, 308 insertions, 147 deletions
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index af33e45668c..74f125e0ad3 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -19,13 +19,18 @@
# <pep8 compliant>
import bpy
-from bpy.props import StringProperty, BoolProperty, IntProperty, \
- FloatProperty, EnumProperty
+from bpy.types import Menu, Operator
+from bpy.props import (StringProperty,
+ BoolProperty,
+ IntProperty,
+ FloatProperty,
+ EnumProperty,
+ )
from rna_prop_ui import rna_idprop_ui_prop_get, rna_idprop_ui_prop_clear
-class MESH_OT_delete_edgeloop(bpy.types.Operator):
+class MESH_OT_delete_edgeloop(Operator):
'''Delete an edge loop by merging the faces on each side to a single face loop'''
bl_idname = "mesh.delete_edgeloop"
bl_label = "Delete Edge Loop"
@@ -38,23 +43,30 @@ class MESH_OT_delete_edgeloop(bpy.types.Operator):
return {'CANCELLED'}
-rna_path_prop = StringProperty(name="Context Attributes",
- description="rna context string", maxlen=1024, default="")
+rna_path_prop = StringProperty(
+ name="Context Attributes",
+ description="rna context string",
+ maxlen=1024,
+ )
-rna_reverse_prop = BoolProperty(name="Reverse",
- description="Cycle backwards", default=False)
+rna_reverse_prop = BoolProperty(
+ name="Reverse",
+ description="Cycle backwards",
+ default=False,
+ )
-rna_relative_prop = BoolProperty(name="Relative",
+rna_relative_prop = BoolProperty(
+ name="Relative",
description="Apply relative to the current value (delta)",
- default=False)
+ default=False,
+ )
def context_path_validate(context, data_path):
- import sys
try:
value = eval("context.%s" % data_path) if data_path else Ellipsis
- except AttributeError:
- if "'NoneType'" in str(sys.exc_info()[1]):
+ except AttributeError as e:
+ if str(e).startswith("'NoneType'"):
# One of the items in the rna path is None, just ignore this
value = Ellipsis
else:
@@ -64,32 +76,87 @@ def context_path_validate(context, data_path):
return value
+def operator_value_is_undo(value):
+ if value in {None, Ellipsis}:
+ return False
+
+ # typical properties or objects
+ id_data = getattr(value, "id_data", Ellipsis)
+
+ if id_data is None:
+ return False
+ elif id_data is Ellipsis:
+ # handle mathutils types
+ id_data = getattr(getattr(value, "owner", None), "id_data", None)
+
+ if id_data is None:
+ return False
+
+ # return True if its a non window ID type
+ return (isinstance(id_data, bpy.types.ID) and
+ (not isinstance(id_data, (bpy.types.WindowManager,
+ bpy.types.Screen,
+ bpy.types.Scene,
+ bpy.types.Brush,
+ ))))
+
+
+def operator_path_is_undo(context, data_path):
+ # note that if we have data paths that use strings this could fail
+ # luckily we dont do this!
+ #
+ # When we cant find the data owner assume no undo is needed.
+ data_path_head, data_path_sep, data_path_tail = data_path.rpartition(".")
+
+ if not data_path_head:
+ return False
+
+ value = context_path_validate(context, data_path_head)
+
+ return operator_value_is_undo(value)
+
+
+def operator_path_undo_return(context, data_path):
+ return {'FINISHED'} if operator_path_is_undo(context, data_path) else {'CANCELLED'}
+
+
+def operator_value_undo_return(value):
+ return {'FINISHED'} if operator_value_is_undo(value) else {'CANCELLED'}
+
+
def execute_context_assign(self, context):
- if context_path_validate(context, self.data_path) is Ellipsis:
+ data_path = self.data_path
+ if context_path_validate(context, data_path) is Ellipsis:
return {'PASS_THROUGH'}
if getattr(self, "relative", False):
- exec("context.%s+=self.value" % self.data_path)
+ exec("context.%s += self.value" % data_path)
else:
- exec("context.%s=self.value" % self.data_path)
+ exec("context.%s = self.value" % data_path)
- return {'FINISHED'}
+ return operator_path_undo_return(context, data_path)
-class BRUSH_OT_active_index_set(bpy.types.Operator):
+class BRUSH_OT_active_index_set(Operator):
'''Set active sculpt/paint brush from it's number'''
bl_idname = "brush.active_index_set"
bl_label = "Set Brush Number"
- mode = StringProperty(name="mode",
- description="Paint mode to set brush for", maxlen=1024)
- index = IntProperty(name="number",
- description="Brush number")
+ mode = StringProperty(
+ name="mode",
+ description="Paint mode to set brush for",
+ maxlen=1024,
+ )
+ index = IntProperty(
+ name="number",
+ description="Brush number",
+ )
_attr_dict = {"sculpt": "use_paint_sculpt",
"vertex_paint": "use_paint_vertex",
"weight_paint": "use_paint_weight",
- "image_paint": "use_paint_image"}
+ "image_paint": "use_paint_image",
+ }
def execute(self, context):
attr = self._attr_dict.get(self.mode)
@@ -104,50 +171,63 @@ class BRUSH_OT_active_index_set(bpy.types.Operator):
return {'CANCELLED'}
-class WM_OT_context_set_boolean(bpy.types.Operator):
+class WM_OT_context_set_boolean(Operator):
'''Set a context value.'''
bl_idname = "wm.context_set_boolean"
bl_label = "Context Set Boolean"
bl_options = {'UNDO', 'INTERNAL'}
data_path = rna_path_prop
- value = BoolProperty(name="Value",
- description="Assignment value", default=True)
+ value = BoolProperty(
+ name="Value",
+ description="Assignment value",
+ default=True,
+ )
execute = execute_context_assign
-class WM_OT_context_set_int(bpy.types.Operator): # same as enum
+class WM_OT_context_set_int(Operator): # same as enum
'''Set a context value.'''
bl_idname = "wm.context_set_int"
bl_label = "Context Set"
bl_options = {'UNDO', 'INTERNAL'}
data_path = rna_path_prop
- value = IntProperty(name="Value", description="Assign value", default=0)
+ value = IntProperty(
+ name="Value",
+ description="Assign value",
+ default=0,
+ )
relative = rna_relative_prop
execute = execute_context_assign
-class WM_OT_context_scale_int(bpy.types.Operator):
+class WM_OT_context_scale_int(Operator):
'''Scale an int context value.'''
bl_idname = "wm.context_scale_int"
bl_label = "Context Set"
bl_options = {'UNDO', 'INTERNAL'}
data_path = rna_path_prop
- value = FloatProperty(name="Value", description="Assign value", default=1.0)
- always_step = BoolProperty(name="Always Step",
- description="Always adjust the value by a minimum of 1 when 'value' is not 1.0.",
- default=True)
+ value = FloatProperty(
+ name="Value",
+ description="Assign value",
+ default=1.0,
+ )
+ always_step = BoolProperty(
+ name="Always Step",
+ description="Always adjust the value by a minimum of 1 when 'value' is not 1.0.",
+ default=True,
+ )
def execute(self, context):
- if context_path_validate(context, self.data_path) is Ellipsis:
+ data_path = self.data_path
+ if context_path_validate(context, data_path) is Ellipsis:
return {'PASS_THROUGH'}
value = self.value
- data_path = self.data_path
if value == 1.0: # nothing to do
return {'CANCELLED'}
@@ -159,73 +239,85 @@ class WM_OT_context_scale_int(bpy.types.Operator):
else:
add = "-1"
func = "min"
- exec("context.%s = %s(round(context.%s * value), context.%s + %s)" % (data_path, func, data_path, data_path, add))
+ exec("context.%s = %s(round(context.%s * value), context.%s + %s)" %
+ (data_path, func, data_path, data_path, add))
else:
- exec("context.%s *= value" % self.data_path)
+ exec("context.%s *= value" % data_path)
- return {'FINISHED'}
+ return operator_path_undo_return(context, data_path)
-class WM_OT_context_set_float(bpy.types.Operator): # same as enum
+class WM_OT_context_set_float(Operator): # same as enum
'''Set a context value.'''
bl_idname = "wm.context_set_float"
bl_label = "Context Set Float"
bl_options = {'UNDO', 'INTERNAL'}
data_path = rna_path_prop
- value = FloatProperty(name="Value",
- description="Assignment value", default=0.0)
+ value = FloatProperty(
+ name="Value",
+ description="Assignment value",
+ default=0.0,
+ )
relative = rna_relative_prop
execute = execute_context_assign
-class WM_OT_context_set_string(bpy.types.Operator): # same as enum
+class WM_OT_context_set_string(Operator): # same as enum
'''Set a context value.'''
bl_idname = "wm.context_set_string"
bl_label = "Context Set String"
bl_options = {'UNDO', 'INTERNAL'}
data_path = rna_path_prop
- value = StringProperty(name="Value",
- description="Assign value", maxlen=1024, default="")
+ value = StringProperty(
+ name="Value",
+ description="Assign value",
+ maxlen=1024,
+ )
execute = execute_context_assign
-class WM_OT_context_set_enum(bpy.types.Operator):
+class WM_OT_context_set_enum(Operator):
'''Set a context value.'''
bl_idname = "wm.context_set_enum"
bl_label = "Context Set Enum"
bl_options = {'UNDO', 'INTERNAL'}
data_path = rna_path_prop
- value = StringProperty(name="Value",
+ value = StringProperty(
+ name="Value",
description="Assignment value (as a string)",
- maxlen=1024, default="")
+ maxlen=1024,
+ )
execute = execute_context_assign
-class WM_OT_context_set_value(bpy.types.Operator):
+class WM_OT_context_set_value(Operator):
'''Set a context value.'''
bl_idname = "wm.context_set_value"
bl_label = "Context Set Value"
bl_options = {'UNDO', 'INTERNAL'}
data_path = rna_path_prop
- value = StringProperty(name="Value",
+ value = StringProperty(
+ name="Value",
description="Assignment value (as a string)",
- maxlen=1024, default="")
+ maxlen=1024,
+ )
def execute(self, context):
- if context_path_validate(context, self.data_path) is Ellipsis:
+ data_path = self.data_path
+ if context_path_validate(context, data_path) is Ellipsis:
return {'PASS_THROUGH'}
- exec("context.%s=%s" % (self.data_path, self.value))
- return {'FINISHED'}
+ exec("context.%s = %s" % (data_path, self.value))
+ return operator_path_undo_return(context, data_path)
-class WM_OT_context_toggle(bpy.types.Operator):
+class WM_OT_context_toggle(Operator):
'''Toggle a context value.'''
bl_idname = "wm.context_toggle"
bl_label = "Context Toggle"
@@ -234,43 +326,50 @@ class WM_OT_context_toggle(bpy.types.Operator):
data_path = rna_path_prop
def execute(self, context):
+ data_path = self.data_path
- if context_path_validate(context, self.data_path) is Ellipsis:
+ if context_path_validate(context, data_path) is Ellipsis:
return {'PASS_THROUGH'}
- exec("context.%s=not (context.%s)" %
- (self.data_path, self.data_path))
+ exec("context.%s = not (context.%s)" % (data_path, data_path))
- return {'FINISHED'}
+ return operator_path_undo_return(context, data_path)
-class WM_OT_context_toggle_enum(bpy.types.Operator):
+class WM_OT_context_toggle_enum(Operator):
'''Toggle a context value.'''
bl_idname = "wm.context_toggle_enum"
bl_label = "Context Toggle Values"
bl_options = {'UNDO', 'INTERNAL'}
data_path = rna_path_prop
- value_1 = StringProperty(name="Value", \
- description="Toggle enum", maxlen=1024, default="")
-
- value_2 = StringProperty(name="Value", \
- description="Toggle enum", maxlen=1024, default="")
+ value_1 = StringProperty(
+ name="Value",
+ description="Toggle enum",
+ maxlen=1024,
+ )
+ value_2 = StringProperty(
+ name="Value",
+ description="Toggle enum",
+ maxlen=1024,
+ )
def execute(self, context):
+ data_path = self.data_path
- if context_path_validate(context, self.data_path) is Ellipsis:
+ if context_path_validate(context, data_path) is Ellipsis:
return {'PASS_THROUGH'}
- exec("context.%s = ['%s', '%s'][context.%s!='%s']" % \
- (self.data_path, self.value_1,\
- self.value_2, self.data_path,
- self.value_2))
+ exec("context.%s = ('%s', '%s')[context.%s != '%s']" %
+ (data_path, self.value_1,
+ self.value_2, data_path,
+ self.value_2,
+ ))
- return {'FINISHED'}
+ return operator_path_undo_return(context, data_path)
-class WM_OT_context_cycle_int(bpy.types.Operator):
+class WM_OT_context_cycle_int(Operator):
'''Set a context value. Useful for cycling active material, '''
'''vertex keys, groups' etc.'''
bl_idname = "wm.context_cycle_int"
@@ -291,7 +390,7 @@ class WM_OT_context_cycle_int(bpy.types.Operator):
else:
value += 1
- exec("context.%s=value" % data_path)
+ exec("context.%s = value" % data_path)
if value != eval("context.%s" % data_path):
# relies on rna clamping int's out of the range
@@ -300,12 +399,12 @@ class WM_OT_context_cycle_int(bpy.types.Operator):
else:
value = -1 << 31
- exec("context.%s=value" % data_path)
+ exec("context.%s = value" % data_path)
- return {'FINISHED'}
+ return operator_path_undo_return(context, data_path)
-class WM_OT_context_cycle_enum(bpy.types.Operator):
+class WM_OT_context_cycle_enum(Operator):
'''Toggle a context value.'''
bl_idname = "wm.context_cycle_enum"
bl_label = "Context Enum Cycle"
@@ -315,15 +414,15 @@ class WM_OT_context_cycle_enum(bpy.types.Operator):
reverse = rna_reverse_prop
def execute(self, context):
-
- value = context_path_validate(context, self.data_path)
+ data_path = self.data_path
+ value = context_path_validate(context, data_path)
if value is Ellipsis:
return {'PASS_THROUGH'}
orig_value = value
# Have to get rna enum values
- rna_struct_str, rna_prop_str = self.data_path.rsplit('.', 1)
+ rna_struct_str, rna_prop_str = data_path.rsplit('.', 1)
i = rna_prop_str.find('[')
# just incse we get "context.foo.bar[0]"
@@ -353,11 +452,11 @@ 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.data_path)
- return {'FINISHED'}
+ exec("context.%s = advance_enum" % data_path)
+ return operator_path_undo_return(context, data_path)
-class WM_OT_context_cycle_array(bpy.types.Operator):
+class WM_OT_context_cycle_array(Operator):
'''Set a context array value.
Useful for cycling the active mesh edit mode.'''
bl_idname = "wm.context_cycle_array"
@@ -380,12 +479,12 @@ class WM_OT_context_cycle_array(bpy.types.Operator):
array.append(array.pop(0))
return array
- exec("context.%s=cycle(context.%s[:])" % (data_path, data_path))
+ exec("context.%s = cycle(context.%s[:])" % (data_path, data_path))
- return {'FINISHED'}
+ return operator_path_undo_return(context, data_path)
-class WM_MT_context_menu_enum(bpy.types.Menu):
+class WM_MT_context_menu_enum(Menu):
bl_label = ""
data_path = "" # BAD DESIGN, set from operator below.
@@ -405,7 +504,7 @@ class WM_MT_context_menu_enum(bpy.types.Menu):
prop.value = identifier
-class WM_OT_context_menu_enum(bpy.types.Operator):
+class WM_OT_context_menu_enum(Operator):
bl_idname = "wm.context_menu_enum"
bl_label = "Context Enum Menu"
bl_options = {'UNDO', 'INTERNAL'}
@@ -418,15 +517,18 @@ class WM_OT_context_menu_enum(bpy.types.Operator):
return {'PASS_THROUGH'}
-class WM_OT_context_set_id(bpy.types.Operator):
+class WM_OT_context_set_id(Operator):
'''Toggle a context value.'''
bl_idname = "wm.context_set_id"
bl_label = "Set Library ID"
bl_options = {'UNDO', 'INTERNAL'}
data_path = rna_path_prop
- value = StringProperty(name="Value",
- description="Assign value", maxlen=1024, default="")
+ value = StringProperty(
+ name="Value",
+ description="Assign value",
+ maxlen=1024,
+ )
def execute(self, context):
value = self.value
@@ -448,16 +550,21 @@ class WM_OT_context_set_id(bpy.types.Operator):
if id_iter:
value_id = getattr(bpy.data, id_iter).get(value)
- exec("context.%s=value_id" % data_path)
+ exec("context.%s = value_id" % data_path)
- return {'FINISHED'}
+ return operator_path_undo_return(context, data_path)
-doc_id = StringProperty(name="Doc ID",
- description="", maxlen=1024, default="", options={'HIDDEN'})
+doc_id = StringProperty(
+ name="Doc ID",
+ maxlen=1024,
+ options={'HIDDEN'},
+ )
-doc_new = StringProperty(name="Edit Description",
- description="", maxlen=1024, default="")
+doc_new = StringProperty(
+ name="Edit Description",
+ maxlen=1024,
+ )
data_path_iter = StringProperty(
description="The data path relative to the context, must point to an iterable.")
@@ -466,7 +573,7 @@ data_path_item = StringProperty(
description="The data path from each iterable to the value (int or float)")
-class WM_OT_context_collection_boolean_set(bpy.types.Operator):
+class WM_OT_context_collection_boolean_set(Operator):
'''Set boolean values for a collection of items'''
bl_idname = "wm.context_collection_boolean_set"
bl_label = "Context Collection Boolean Set"
@@ -475,12 +582,13 @@ class WM_OT_context_collection_boolean_set(bpy.types.Operator):
data_path_iter = data_path_iter
data_path_item = data_path_item
- type = EnumProperty(items=(
- ('TOGGLE', "Toggle", ""),
- ('ENABLE', "Enable", ""),
- ('DISABLE', "Disable", ""),
- ),
- name="Type")
+ type = EnumProperty(
+ name="Type",
+ items=(('TOGGLE', "Toggle", ""),
+ ('ENABLE', "Enable", ""),
+ ('DISABLE', "Disable", ""),
+ ),
+ )
def execute(self, context):
data_path_iter = self.data_path_iter
@@ -506,6 +614,10 @@ class WM_OT_context_collection_boolean_set(bpy.types.Operator):
items_ok.append(item)
+ # avoid undo push when nothing to do
+ if not items_ok:
+ return {'CANCELLED'}
+
if self.type == 'ENABLE':
is_set = True
elif self.type == 'DISABLE':
@@ -517,20 +629,26 @@ class WM_OT_context_collection_boolean_set(bpy.types.Operator):
for item in items_ok:
exec(exec_str)
- return {'FINISHED'}
+ return operator_value_undo_return(item)
-class WM_OT_context_modal_mouse(bpy.types.Operator):
+class WM_OT_context_modal_mouse(Operator):
'''Adjust arbitrary values with mouse input'''
bl_idname = "wm.context_modal_mouse"
bl_label = "Context Modal Mouse"
- bl_options = {'GRAB_POINTER', 'BLOCKING', 'INTERNAL'}
+ bl_options = {'GRAB_POINTER', 'BLOCKING', 'UNDO', 'INTERNAL'}
data_path_iter = data_path_iter
data_path_item = data_path_item
- input_scale = FloatProperty(default=0.01, description="Scale the mouse movement by this value before applying the delta")
- invert = BoolProperty(default=False, description="Invert the mouse input")
+ input_scale = FloatProperty(
+ description="Scale the mouse movement by this value before applying the delta",
+ default=0.01,
+ )
+ invert = BoolProperty(
+ description="Invert the mouse input",
+ default=False,
+ )
initial_x = IntProperty(options={'HIDDEN'})
def _values_store(self, context):
@@ -583,12 +701,13 @@ class WM_OT_context_modal_mouse(bpy.types.Operator):
self._values_delta(delta)
elif 'LEFTMOUSE' == event_type:
+ item = next(iter(self._values.keys()))
self._values_clear()
- return {'FINISHED'}
+ return operator_value_undo_return(item)
- elif event_type in ('RIGHTMOUSE', 'ESC'):
+ elif event_type in {'RIGHTMOUSE', 'ESC'}:
self._values_restore()
- return {'FINISHED'}
+ return {'CANCELLED'}
return {'RUNNING_MODAL'}
@@ -607,12 +726,15 @@ class WM_OT_context_modal_mouse(bpy.types.Operator):
return {'RUNNING_MODAL'}
-class WM_OT_url_open(bpy.types.Operator):
+class WM_OT_url_open(Operator):
"Open a website in the Webbrowser"
bl_idname = "wm.url_open"
bl_label = ""
- url = StringProperty(name="URL", description="URL to open")
+ url = StringProperty(
+ name="URL",
+ description="URL to open",
+ )
def execute(self, context):
import webbrowser
@@ -621,12 +743,16 @@ class WM_OT_url_open(bpy.types.Operator):
return {'FINISHED'}
-class WM_OT_path_open(bpy.types.Operator):
+class WM_OT_path_open(Operator):
"Open a path in a file browser"
bl_idname = "wm.path_open"
bl_label = ""
- filepath = StringProperty(name="File Path", maxlen=1024, subtype='FILE_PATH')
+ filepath = StringProperty(
+ name="File Path",
+ maxlen=1024,
+ subtype='FILE_PATH',
+ )
def execute(self, context):
import sys
@@ -654,16 +780,18 @@ class WM_OT_path_open(bpy.types.Operator):
return {'FINISHED'}
-class WM_OT_doc_view(bpy.types.Operator):
+class WM_OT_doc_view(Operator):
'''Load online reference docs'''
bl_idname = "wm.doc_view"
bl_label = "View Documentation"
doc_id = doc_id
if bpy.app.version_cycle == "release":
- _prefix = "http://www.blender.org/documentation/blender_python_api_%s%s_release" % ("_".join(str(v) for v in bpy.app.version[:2]), bpy.app.version_char)
+ _prefix = ("http://www.blender.org/documentation/blender_python_api_%s%s_release" %
+ ("_".join(str(v) for v in bpy.app.version[:2]), bpy.app.version_char))
else:
- _prefix = "http://www.blender.org/documentation/blender_python_api_%s" % "_".join(str(v) for v in bpy.app.version)
+ _prefix = ("http://www.blender.org/documentation/blender_python_api_%s" %
+ "_".join(str(v) for v in bpy.app.version))
def _nested_class_string(self, class_string):
ls = []
@@ -681,8 +809,8 @@ class WM_OT_doc_view(bpy.types.Operator):
class_name, class_prop = id_split
if hasattr(bpy.types, class_name.upper() + '_OT_' + class_prop):
- url = '%s/bpy.ops.%s.html#bpy.ops.%s.%s' % \
- (self._prefix, class_name, class_name, class_prop)
+ url = ("%s/bpy.ops.%s.html#bpy.ops.%s.%s" %
+ (self._prefix, class_name, class_name, class_prop))
else:
# detect if this is a inherited member and use that name instead
@@ -695,8 +823,8 @@ class WM_OT_doc_view(bpy.types.Operator):
# It so happens that epydoc nests these, not sphinx
# class_name_full = self._nested_class_string(class_name)
- url = '%s/bpy.types.%s.html#bpy.types.%s.%s' % \
- (self._prefix, class_name, class_name, class_prop)
+ url = ("%s/bpy.types.%s.html#bpy.types.%s.%s" %
+ (self._prefix, class_name, class_name, class_prop))
else:
return {'PASS_THROUGH'}
@@ -708,7 +836,7 @@ class WM_OT_doc_view(bpy.types.Operator):
return {'FINISHED'}
-class WM_OT_doc_edit(bpy.types.Operator):
+class WM_OT_doc_edit(Operator):
'''Load online reference docs'''
bl_idname = "wm.doc_edit"
bl_label = "Edit Documentation"
@@ -779,20 +907,39 @@ class WM_OT_doc_edit(bpy.types.Operator):
return wm.invoke_props_dialog(self, width=600)
-rna_path = StringProperty(name="Property Edit",
- description="Property data_path edit", maxlen=1024, default="", options={'HIDDEN'})
+rna_path = StringProperty(
+ name="Property Edit",
+ description="Property data_path edit",
+ maxlen=1024,
+ options={'HIDDEN'},
+ )
+
+rna_value = StringProperty(
+ name="Property Value",
+ description="Property value edit",
+ maxlen=1024,
+ )
-rna_value = StringProperty(name="Property Value",
- description="Property value edit", maxlen=1024, default="")
+rna_property = StringProperty(
+ name="Property Name",
+ description="Property name edit",
+ maxlen=1024,
+ )
-rna_property = StringProperty(name="Property Name",
- description="Property name edit", maxlen=1024, default="")
+rna_min = FloatProperty(
+ name="Min",
+ default=0.0,
+ precision=3,
+ )
-rna_min = FloatProperty(name="Min", default=0.0, precision=3)
-rna_max = FloatProperty(name="Max", default=1.0, precision=3)
+rna_max = FloatProperty(
+ name="Max",
+ default=1.0,
+ precision=3,
+ )
-class WM_OT_properties_edit(bpy.types.Operator):
+class WM_OT_properties_edit(Operator):
'''Internal use (edit a property data_path)'''
bl_idname = "wm.properties_edit"
bl_label = "Edit Property"
@@ -803,7 +950,9 @@ class WM_OT_properties_edit(bpy.types.Operator):
value = rna_value
min = rna_min
max = rna_max
- description = StringProperty(name="Tip", default="")
+ description = StringProperty(
+ name="Tip",
+ )
def execute(self, context):
data_path = self.data_path
@@ -839,7 +988,7 @@ class WM_OT_properties_edit(bpy.types.Operator):
prop_ui = rna_idprop_ui_prop_get(item, prop)
- if prop_type in (float, int):
+ if prop_type in {float, int}:
prop_ui['soft_min'] = prop_ui['min'] = prop_type(self.min)
prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.max)
@@ -856,14 +1005,15 @@ class WM_OT_properties_edit(bpy.types.Operator):
return {'FINISHED'}
def invoke(self, context, event):
+ data_path = self.data_path
- if not self.data_path:
+ if not data_path:
self.report({'ERROR'}, "Data path not set")
return {'CANCELLED'}
self._last_prop = [self.property]
- item = eval("context.%s" % self.data_path)
+ item = eval("context.%s" % data_path)
# setup defaults
prop_ui = rna_idprop_ui_prop_get(item, self.property, False) # dont create
@@ -876,7 +1026,7 @@ class WM_OT_properties_edit(bpy.types.Operator):
return wm.invoke_props_dialog(self)
-class WM_OT_properties_add(bpy.types.Operator):
+class WM_OT_properties_add(Operator):
'''Internal use (edit a property data_path)'''
bl_idname = "wm.properties_add"
bl_label = "Add Property"
@@ -884,7 +1034,8 @@ class WM_OT_properties_add(bpy.types.Operator):
data_path = rna_path
def execute(self, context):
- item = eval("context.%s" % self.data_path)
+ data_path = self.data_path
+ item = eval("context.%s" % data_path)
def unique_name(names):
prop = 'prop'
@@ -902,19 +1053,22 @@ class WM_OT_properties_add(bpy.types.Operator):
return {'FINISHED'}
-class WM_OT_properties_context_change(bpy.types.Operator):
+class WM_OT_properties_context_change(Operator):
"Change the context tab in a Properties Window"
bl_idname = "wm.properties_context_change"
bl_label = ""
- context = StringProperty(name="Context", maxlen=32)
+ context = StringProperty(
+ name="Context",
+ maxlen=32,
+ )
def execute(self, context):
- context.space_data.context = (self.context)
+ context.space_data.context = self.context
return {'FINISHED'}
-class WM_OT_properties_remove(bpy.types.Operator):
+class WM_OT_properties_remove(Operator):
'''Internal use (edit a property data_path)'''
bl_idname = "wm.properties_remove"
bl_label = "Remove Property"
@@ -923,23 +1077,27 @@ class WM_OT_properties_remove(bpy.types.Operator):
property = rna_property
def execute(self, context):
- item = eval("context.%s" % self.data_path)
+ data_path = self.data_path
+ item = eval("context.%s" % data_path)
del item[self.property]
return {'FINISHED'}
-class WM_OT_keyconfig_activate(bpy.types.Operator):
+class WM_OT_keyconfig_activate(Operator):
bl_idname = "wm.keyconfig_activate"
bl_label = "Activate Keyconfig"
- filepath = StringProperty(name="File Path", maxlen=1024)
+ filepath = StringProperty(
+ name="File Path",
+ maxlen=1024,
+ )
def execute(self, context):
bpy.utils.keyconfig_set(self.filepath)
return {'FINISHED'}
-class WM_OT_appconfig_default(bpy.types.Operator):
+class WM_OT_appconfig_default(Operator):
bl_idname = "wm.appconfig_default"
bl_label = "Default Application Configuration"
@@ -956,11 +1114,14 @@ class WM_OT_appconfig_default(bpy.types.Operator):
return {'FINISHED'}
-class WM_OT_appconfig_activate(bpy.types.Operator):
+class WM_OT_appconfig_activate(Operator):
bl_idname = "wm.appconfig_activate"
bl_label = "Activate Application Configuration"
- filepath = StringProperty(name="File Path", maxlen=1024)
+ filepath = StringProperty(
+ name="File Path",
+ maxlen=1024,
+ )
def execute(self, context):
import os
@@ -974,7 +1135,7 @@ class WM_OT_appconfig_activate(bpy.types.Operator):
return {'FINISHED'}
-class WM_OT_sysinfo(bpy.types.Operator):
+class WM_OT_sysinfo(Operator):
'''Generate System Info'''
bl_idname = "wm.sysinfo"
bl_label = "System Info"
@@ -985,7 +1146,7 @@ class WM_OT_sysinfo(bpy.types.Operator):
return {'FINISHED'}
-class WM_OT_copy_prev_settings(bpy.types.Operator):
+class WM_OT_copy_prev_settings(Operator):
'''Copy settings from previous version'''
bl_idname = "wm.copy_prev_settings"
bl_label = "Copy Previous Settings"