[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45599] trunk/blender/release/scripts/ startup: Move "From Cursor" operator which sets dupli group offset to own operator
Sergey Sharybin
sergey.vfx at gmail.com
Fri Apr 13 14:14:20 CEST 2012
Revision: 45599
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45599
Author: nazgul
Date: 2012-04-13 12:14:20 +0000 (Fri, 13 Apr 2012)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_operators/object.py
trunk/blender/release/scripts/startup/bl_ui/properties_object.py
Modified: trunk/blender/release/scripts/startup/bl_operators/object.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/object.py 2012-04-13 12:12:54 UTC (rev 45598)
+++ trunk/blender/release/scripts/startup/bl_operators/object.py 2012-04-13 12:14:20 UTC (rev 45599)
@@ -691,3 +691,29 @@
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'}
Modified: trunk/blender/release/scripts/startup/bl_ui/properties_object.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_object.py 2012-04-13 12:12:54 UTC (rev 45598)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_object.py 2012-04-13 12:14:20 UTC (rev 45599)
@@ -162,7 +162,6 @@
# 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 @@
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
More information about the Bf-blender-cvs
mailing list