Skip to content

Instantly share code, notes, and snippets.

@gifguide2code
Created July 22, 2018 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gifguide2code/3d45ee96928587f6e9ae20e7cc33eb81 to your computer and use it in GitHub Desktop.
Save gifguide2code/3d45ee96928587f6e9ae20e7cc33eb81 to your computer and use it in GitHub Desktop.
The code for an add-on that generates 100 spheres at random locations in a 20 x 20 space at the center of a Blender scene.
bl_info = {
"name": "Fireflies",
"author": "GifGuide2Code",
"version": (1,0,0),
"category": "Object",
}
import bpy
import random
class fireflies(bpy.types.Operator):
"""Fireflies"""
bl_idname = "object.fireflies"
bl_label = "Create fireflies"
def execute(self, context):
x=1
y=1
z=1
for index in range(100):
bpy.ops.mesh.primitive_uv_sphere_add(size=.02,location=(x,y,z))
x=random.randint(-10,10)
y=random.randint(-10,10)
z=random.randint(-10,10)
return{'FINISHED'}
def register():
bpy.utils.register_class(fireflies)
def unregister():
bpy.utils.register_class(fireflies)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment