[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2520] contrib/py/scripts/addons/ object_drop_to_ground.py: ok i got it to work, it seems object. location was creating the problem so i used the operator translate and it works now .
james bond
thekilon at yahoo.co.uk
Tue Oct 25 15:26:33 CEST 2011
Revision: 2520
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2520
Author: kilon
Date: 2011-10-25 13:26:33 +0000 (Tue, 25 Oct 2011)
Log Message:
-----------
ok i got it to work, it seems object.location was creating the problem so i used the operator translate and it works now. I also implemented a gui with min max , for x,y,z axis to make randomisation more precise. Well keep testing, if randomisation exceeds boundaries of ground then the object will not drop on the ground which i think its normal behaviour, will also put a warning at the wiki
Modified Paths:
--------------
contrib/py/scripts/addons/object_drop_to_ground.py
Modified: contrib/py/scripts/addons/object_drop_to_ground.py
===================================================================
--- contrib/py/scripts/addons/object_drop_to_ground.py 2011-10-25 12:15:06 UTC (rev 2519)
+++ contrib/py/scripts/addons/object_drop_to_ground.py 2011-10-25 13:26:33 UTC (rev 2520)
@@ -122,12 +122,14 @@
for ob in obs:
bpy.ops.object.select_all(action='DESELECT')
ob.select = True
+
+ #randomise location it its enabled
if sc.random_loc :
print("randomising the location of object : ", ob.name)
print("current location :" + str(ob.location))
- ob.location = (compute_percentage(0,100,ob.location[0],10),
- compute_percentage(0,100,ob.location[1],10),
- compute_percentage(0,100,ob.location[2],10))
+ bpy.ops.transform.translate(value=(compute_percentage(sc.rl_min_x,sc.rl_max_x,0,100),
+ compute_percentage(sc.rl_min_y,sc.rl_max_y,0,100),
+ compute_percentage(sc.rl_min_z,sc.rl_max_z,0,100)))
print("randomised location : ", str(ob.location))
do_drop(context, tmpObj, ob)
@@ -153,8 +155,26 @@
col.operator("object.drop_to_ground", text="Drop")
col.prop(context.scene, "align_object")
col.prop(context.scene, "use_center")
- # col.prop(context.scene, "random_loc")
+ box= layout.box()
+ box.prop(context.scene, "random_loc")
+ # random location gui appears only if its enabled
+ if bpy.context.scene.random_loc:
+
+ row = box.row()
+ row.label(text="(X,Y,Z) [min/max]")
+ row = box.row()
+ a = row.split(percentage = 0.5, align = True)
+ a.prop(context.scene, "rl_min_x")
+ a.prop(context.scene, "rl_max_x")
+ row = box.row()
+ b = row.split(percentage = 0.5, align = True)
+ b.prop(context.scene, "rl_min_y")
+ b.prop(context.scene, "rl_max_y")
+ row = box.row()
+ b = row.split(percentage = 0.5, align = True)
+ b.prop(context.scene, "rl_min_z")
+ b.prop(context.scene, "rl_max_z")
class OBJECT_OT_drop_to_ground(bpy.types.Operator):
"""Drop to ground"""
@@ -181,15 +201,30 @@
name="Use the center to drop",
description="When dropping the object will be relocated on the basis of its senter",
default=False)
+
+ #random location props
bpy.types.Scene.random_loc = BoolProperty(
name="Random Location",
description="When dropping the object will be relocated randomly ",
default=False)
-
+ bpy.types.Scene.rl_min_x = IntProperty(name="min", description = " Minimum of location randomisation while droped to the ground for the x axis", default = 0)
+ bpy.types.Scene.rl_max_x = IntProperty(name="max", description = " Maximum of location randomisation while droped to the ground for the x axis", default = 0)
+ bpy.types.Scene.rl_min_y = IntProperty(name="min", description = " Minimum of location randomisation while droped to the ground for the y axis", default = 0)
+ bpy.types.Scene.rl_max_y = IntProperty(name="max", description = " Maximum of location randomisation while droped to the ground for the y axis", default = 0)
+ bpy.types.Scene.rl_min_z = IntProperty(name="min", description = " Minimum of location randomisation while droped to the ground for the z axis", default = 0)
+ bpy.types.Scene.rl_max_z = IntProperty(name="max", description = " Maximum of location randomisation while droped to the ground for the z axis", default = 0)
+
def unregister():
bpy.utils.unregister_module(__name__)
del bpy.types.Scene.align_object
del bpy.types.Scene.use_center
del bpy.types.Scene.random_loc
+ del bpy.types.Scene.rl_min_x
+ del bpy.types.Scene.rl_max_x
+ del bpy.types.Scene.rl_min_y
+ del bpy.types.Scene.rl_max_y
+ del bpy.types.Scene.rl_min_z
+ del bpy.types.Scene.rl_max_z
+
if __name__ == '__main__':
register()
More information about the Bf-extensions-cvs
mailing list