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/op')
-rw-r--r--release/scripts/op/console_python.py2
-rw-r--r--release/scripts/op/object.py46
-rw-r--r--release/scripts/op/presets.py12
-rw-r--r--release/scripts/op/uv.py3
4 files changed, 40 insertions, 23 deletions
diff --git a/release/scripts/op/console_python.py b/release/scripts/op/console_python.py
index 83a3130f80e..d3a90cb7acc 100644
--- a/release/scripts/op/console_python.py
+++ b/release/scripts/op/console_python.py
@@ -68,7 +68,7 @@ def get_console(console_id):
stderr = io.StringIO()
else:
namespace = {'__builtins__': __builtins__, 'bpy': bpy}
- console = InteractiveConsole(namespace)
+ console = InteractiveConsole(locals=namespace, filename="<blender_console>")
import io
stdout = io.StringIO()
diff --git a/release/scripts/op/object.py b/release/scripts/op/object.py
index e76218e4637..b16d2b0dcf2 100644
--- a/release/scripts/op/object.py
+++ b/release/scripts/op/object.py
@@ -113,24 +113,42 @@ class SelectHierarchy(bpy.types.Operator):
return context.object
def execute(self, context):
- obj = context.object
- if self.properties.direction == 'PARENT':
- parent = obj.parent
- if not parent:
- return {'CANCELLED'}
- obj_act = parent
- else:
- children = obj.children
- if len(children) != 1:
- return {'CANCELLED'}
- obj_act = children[0]
+ objs = context.selected_objects
+ obj_act = context.object
+
+ if context.object not in objs:
+ objs.append(context.object)
if not self.properties.extend:
- # obj.selected = False
+ # for obj in objs:
+ # obj.selected = False
bpy.ops.object.select_all(action='DESELECT')
- obj_act.selected = True
- context.scene.objects.active = obj_act
+ if self.properties.direction == 'PARENT':
+ parents = []
+ for obj in objs:
+ parent = obj.parent
+
+ if parent:
+ parents.append(parent)
+
+ if obj_act == obj:
+ context.scene.objects.active = parent
+
+ parent.selected = True
+
+ if parents:
+ return {'CANCELLED'}
+
+ else:
+ children = []
+ for obj in objs:
+ children += list(obj.children)
+ for obj_iter in children:
+ obj_iter.selected = True
+
+ children.sort(key=lambda obj_iter: obj_iter.name)
+ context.scene.objects.active = children[0]
return {'FINISHED'}
diff --git a/release/scripts/op/presets.py b/release/scripts/op/presets.py
index a813cb5339d..f80c5e69ddd 100644
--- a/release/scripts/op/presets.py
+++ b/release/scripts/op/presets.py
@@ -27,8 +27,8 @@ class AddPresetBase(bpy.types.Operator):
subclasses must define
- preset_values
- preset_subdir '''
- bl_idname = "script.add_preset_base"
- bl_label = "Add a Python Preset"
+ # bl_idname = "script.preset_base_add"
+ # bl_label = "Add a Python Preset"
name = bpy.props.StringProperty(name="Name", description="Name of the preset, used to make the path name", maxlen=64, default="")
@@ -47,19 +47,17 @@ class AddPresetBase(bpy.types.Operator):
target_path = bpy.utils.preset_paths(self.preset_subdir)[0] # we need some way to tell the user and system preset path
filepath = os.path.join(target_path, filename)
- if getattr(self, "save_keyconfig", True):
+ if getattr(self, "save_keyconfig", False):
bpy.ops.wm.keyconfig_export(filepath=filepath, kc_name=self.properties.name)
file_preset = open(filepath, 'a')
file_preset.write("wm.active_keyconfig = kc\n\n")
else:
file_preset = open(filepath, 'w')
+ file_preset.write("import bpy\n")
for rna_path in self.preset_values:
value = eval(rna_path)
- if type(value) == str:
- value = "'%s'" % value
-
- file_preset.write("%s = %s\n" % (rna_path, value))
+ file_preset.write("%s = %s\n" % (rna_path, repr(value)))
file_preset.close()
diff --git a/release/scripts/op/uv.py b/release/scripts/op/uv.py
index b9bc54bf264..51c1695677b 100644
--- a/release/scripts/op/uv.py
+++ b/release/scripts/op/uv.py
@@ -210,7 +210,8 @@ class ExportUVLayout(bpy.types.Operator):
def menu_func(self, context):
- default_path = bpy.data.filepath.replace(".blend", ".svg")
+ import os
+ default_path = os.path.splitext(bpy.data.filepath)[0] + ".svg"
self.layout.operator(ExportUVLayout.bl_idname).filepath = default_path