Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import bpy
  2. import random
  3.  
  4. x = random.randint(-6, 6)
  5. y = random.randint(-6, 6)
  6. z = random.randint(-6, 6)
  7.  
  8. bpy.ops.mesh.primitive_cube_add(radius=1, location=(x, y, z),)
  9.  
  10. import bpy
  11.  
  12.  
  13. class GlobalScriptRunner(bpy.types.Operator):
  14. """Tooltip"""
  15. bl_idname = "view3d.global_script_runner"
  16. bl_label = "Global Script Runner"
  17.  
  18. #@classmethod
  19. #def poll(cls, context):
  20. # return context.active_object is not None
  21.  
  22. def execute(self, context):
  23. print('i get called')
  24. textblock_name = 'generic_executor.py'
  25. textblock_as_string = bpy.data.texts[textblock_name].as_string()
  26. exec(textblock_as_string)
  27. return {'FINISHED'}
  28.  
  29.  
  30. def register():
  31. bpy.utils.register_class(GlobalScriptRunner)
  32.  
  33.  
  34. def unregister():
  35. bpy.utils.unregister_class(GlobalScriptRunner)
  36.  
  37.  
  38. if __name__ == "__main__":
  39. register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement