Instantly share code, notes, and snippets.

Embed
What would you like to do?
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