Created
July 22, 2018 14:35
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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