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:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-04-13 16:14:20 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-04-13 16:14:20 +0400
commit54e648d114c0e17d60d1df325094a7d1e3fb9e3f (patch)
tree1bdc0310c98ad03c5c6d0df5f9a7e6570c5837f4
parent44258c3c9a7e279832e8b01975f9ba7b91e15688 (diff)
Move "From Cursor" operator which sets dupli group offset to own operator
Previously it used to use cursor location from time when panel was drawn, which in some cases lead to using previous cursor location instead of current.
-rw-r--r--release/scripts/startup/bl_operators/object.py26
-rw-r--r--release/scripts/startup/bl_ui/properties_object.py6
2 files changed, 28 insertions, 4 deletions
diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py
index 433c4403055..4ade55c0af6 100644
--- a/release/scripts/startup/bl_operators/object.py
+++ b/release/scripts/startup/bl_operators/object.py
@@ -691,3 +691,29 @@ class TransformsToDeltasAnim(Operator):
context.scene.frame_set(context.scene.frame_current)
return {'FINISHED'}
+
+
+class DupliOffsetFromCursor(Operator):
+ '''Set offset used for DupliGroup based on cursor position'''
+ bl_idname = "object.dupli_offset_from_cursor"
+ bl_label = "Set Offset From Cursor"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ group = IntProperty(
+ name="Group",
+ description="Group index to set offset for",
+ default=0,
+ )
+
+ @classmethod
+ def poll(cls, context):
+ return context.active_object is not None
+
+ def execute(self, context):
+ scene = context.scene
+ ob = context.active_object
+ group = self.group
+
+ ob.users_group[group].dupli_offset = scene.cursor_location
+
+ return {'FINISHED'}
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index c03aeab1f37..d8d3bd5fd97 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -162,7 +162,6 @@ class OBJECT_PT_groups(ObjectButtonsPanel, Panel):
# XXX, this is bad practice, yes, I wrote it :( - campbell
index = 0
- value = str(tuple(context.scene.cursor_location))
for group in bpy.data.groups:
if ob.name in group.objects:
col = layout.column(align=True)
@@ -181,9 +180,8 @@ class OBJECT_PT_groups(ObjectButtonsPanel, Panel):
col = split.column()
col.prop(group, "dupli_offset", text="")
- props = col.operator("wm.context_set_value", text="From Cursor")
- props.data_path = "object.users_group[%d].dupli_offset" % index
- props.value = value
+ props = col.operator("object.dupli_offset_from_cursor", text="From Cursor")
+ props.index = index
index += 1