<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div><span>Why using an operator is a problem ? looking into the recommended source code. <br></span></div><br><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"><br>------------------------------<br><br>Message: 3<br>Date: Tue, 25 Oct 2011 07:28:22 -0600<br>From: "Daniel Salazar - 3Developer.com" <<a ymailto="mailto:zanqdo@gmail.com" href="mailto:zanqdo@gmail.com">zanqdo@gmail.com</a>><br>Subject: Re: [Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions<br> [2520] contrib/py/scripts/addons/ object_drop_to_ground.py: ok i got<br> it to work, it seems object. location was creating the problem so i<br> used the operator translate and it works now .<br>To: <a
ymailto="mailto:bf-extensions-cvs@blender.org" href="mailto:bf-extensions-cvs@blender.org">bf-extensions-cvs@blender.org</a><br>Message-ID:<br> <<a ymailto="mailto:CABdDwP_AoAhMfwgky7F3R4uUsMFM0G4vuBwvrcRbRxOwbop6UQ@mail.gmail.com" href="mailto:CABdDwP_AoAhMfwgky7F3R4uUsMFM0G4vuBwvrcRbRxOwbop6UQ@mail.gmail.com">CABdDwP_AoAhMfwgky7F3R4uUsMFM0G4vuBwvrcRbRxOwbop6UQ@mail.gmail.com</a>><br>Content-Type: text/plain; charset=UTF-8<br><br>I'd suggest looking into randomize transform operator that does this<br>without using operators<br><br>Daniel Salazar<br>3Developer.com<br><br><br><br>On Tue, Oct 25, 2011 at 7:26 AM, james bond <<a ymailto="mailto:thekilon@yahoo.co.uk" href="mailto:thekilon@yahoo.co.uk">thekilon@yahoo.co.uk</a>> wrote:<br>> Revision: 2520<br>> ? ? ? ? ?<a href="http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2520"
target="_blank">http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2520</a><br>> Author: ? kilon<br>> Date: ? ? 2011-10-25 13:26:33 +0000 (Tue, 25 Oct 2011)<br>> Log Message:<br>> -----------<br>> 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<br>><br>> Modified Paths:<br>> --------------<br>> ? ?contrib/py/scripts/addons/object_drop_to_ground.py<br>><br>> Modified: contrib/py/scripts/addons/object_drop_to_ground.py<br>> ===================================================================<br>> ---
contrib/py/scripts/addons/object_drop_to_ground.py ?2011-10-25 12:15:06 UTC (rev 2519)<br>> +++ contrib/py/scripts/addons/object_drop_to_ground.py ?2011-10-25 13:26:33 UTC (rev 2520)<br>> @@ -122,12 +122,14 @@<br>> ? ? for ob in obs:<br>> ? ? ? ? bpy.ops.object.select_all(action='DESELECT')<br>> ? ? ? ? ob.select = True<br>> +<br>> + ? ? ? ?#randomise location it its enabled<br>> ? ? ? ? if sc.random_loc :<br>> ? ? ? ? ? ? print("randomising the location of object : ", ob.name)<br>> ? ? ? ? ? ? print("current location :" + str(ob.location))<br>> - ? ? ? ? ? ?ob.location = (compute_percentage(0,100,ob.location[0],10),<br>> - ? ? ? ? ? ? ? ? ? ? ? ? ? compute_percentage(0,100,ob.location[1],10),<br>> - ? ? ? ? ? ? ? ? ? ? ? ? ? compute_percentage(0,100,ob.location[2],10))<br>> + ? ? ? ? ? ?bpy.ops.transform.translate(value=(compute_percentage(sc.rl_min_x,sc.rl_max_x,0,100),<br>> + ? ? ? ? ? ? ? ? ? ? ? ? ?
compute_percentage(sc.rl_min_y,sc.rl_max_y,0,100),<br>> + ? ? ? ? ? ? ? ? ? ? ? ? ? compute_percentage(sc.rl_min_z,sc.rl_max_z,0,100)))<br>> ? ? ? ? ? ? print("randomised location : ", str(ob.location))<br>> ? ? ? ? do_drop(context, tmpObj, ob)<br>><br>> @@ -153,8 +155,26 @@<br>> ? ? ? ? col.operator("object.drop_to_ground", text="Drop")<br>> ? ? ? ? col.prop(context.scene, "align_object")<br>> ? ? ? ? col.prop(context.scene, "use_center")<br>> - ? ? ? # col.prop(context.scene, "random_loc")<br>> + ? ? ? ?box= layout.box()<br>> + ? ? ? ?box.prop(context.scene, "random_loc")<br>><br>> + ? ? ? ?# random location gui appears only if its enabled<br>> + ? ? ? ?if bpy.context.scene.random_loc:<br>> +<br>> + ? ? ? ? ? ?row = box.row()<br>> + ? ? ? ? ? ?row.label(text="(X,Y,Z) [min/max]")<br>> + ? ? ? ? ? ?row = box.row()<br>> + ? ? ? ? ? ?a = row.split(percentage = 0.5, align = True)<br>> + ? ? ? ? ?
?a.prop(context.scene, "rl_min_x")<br>> + ? ? ? ? ? ?a.prop(context.scene, "rl_max_x")<br>> + ? ? ? ? ? ?row = box.row()<br>> + ? ? ? ? ? ?b = row.split(percentage = 0.5, align = True)<br>> + ? ? ? ? ? ?b.prop(context.scene, "rl_min_y")<br>> + ? ? ? ? ? ?b.prop(context.scene, "rl_max_y")<br>> + ? ? ? ? ? ?row = box.row()<br>> + ? ? ? ? ? ?b = row.split(percentage = 0.5, align = True)<br>> + ? ? ? ? ? ?b.prop(context.scene, "rl_min_z")<br>> + ? ? ? ? ? ?b.prop(context.scene, "rl_max_z")<br>><br>> ?class OBJECT_OT_drop_to_ground(bpy.types.Operator):<br>> ? ? """Drop to ground"""<br>> @@ -181,15 +201,30 @@<br>> ? ? ? ? name="Use the center to drop",<br>> ? ? ? ? description="When dropping the object will be relocated on the basis of its senter",<br>> ? ? ? ? default=False)<br>> +<br>> + ? ? #random location props<br>> ? ? ?bpy.types.Scene.random_loc = BoolProperty(<br>> ? ? ? ? name="Random
Location",<br>> ? ? ? ? description="When dropping the object will be relocated randomly ",<br>> ? ? ? ? default=False)<br>> -<br>> + ? ? 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)<br>> + ? ? 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)<br>> + ? ? 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)<br>> + ? ? 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)<br>> + ? ? 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)<br>> + ? ? 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)<br>> +<br>> ?def unregister():<br>> ? ? bpy.utils.unregister_module(__name__)<br>> ? ? del bpy.types.Scene.align_object<br>> ? ? del bpy.types.Scene.use_center<br>> ? ? del bpy.types.Scene.random_loc<br>> + ? ?del bpy.types.Scene.rl_min_x<br>> + ? ?del bpy.types.Scene.rl_max_x<br>> + ? ?del bpy.types.Scene.rl_min_y<br>> + ? ?del bpy.types.Scene.rl_max_y<br>> + ? ?del bpy.types.Scene.rl_min_z<br>> + ? ?del bpy.types.Scene.rl_max_z<br>> +<br>> ?if __name__ == '__main__':<br>> ? ? register()<br>><br>> _______________________________________________<br>> Bf-extensions-cvs mailing list<br>> <a ymailto="mailto:Bf-extensions-cvs@blender.org"
href="mailto:Bf-extensions-cvs@blender.org">Bf-extensions-cvs@blender.org</a><br>> <a href="http://lists.blender.org/mailman/listinfo/bf-extensions-cvs" target="_blank">http://lists.blender.org/mailman/listinfo/bf-extensions-cvs</a><br>><br><br><br>------------------------------<br><br>_______________________________________________<br>Bf-extensions-cvs mailing list<br><a ymailto="mailto:Bf-extensions-cvs@blender.org" href="mailto:Bf-extensions-cvs@blender.org">Bf-extensions-cvs@blender.org</a><br><a href="http://lists.blender.org/mailman/listinfo/bf-extensions-cvs" target="_blank">http://lists.blender.org/mailman/listinfo/bf-extensions-cvs</a><br><br><br>End of Bf-extensions-cvs Digest, Vol 85, Issue 6<br>************************************************<br><br><br></div></div></div></body></html>