Created
May 3, 2019 17:21
-
-
Save Piyush3dB/0861dc873368a23dc957d75d84f003a5 to your computer and use it in GitHub Desktop.
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
import bpy | |
from random import randint | |
class Monkey(object): | |
def __init__(self, location=(0,0,0)): | |
self.location = location | |
def add(self): | |
bpy.ops.mesh.primitive_monkey_add(location=self.location) | |
def modify(self, type='SUBSURF'): | |
bpy.ops.object.modifier_add(type=type) | |
#bpy.context.object.modifiers['Subdivision'].render_levels = 3 | |
#bpy.context.object.modifiers['Subdivision'].levels = 3 | |
bpy.ops.object.shade_smooth() | |
class Scene(object): | |
def __init__(self, number): | |
self.objs = [] | |
self.number = number | |
def clear(self): | |
bpy.ops.object.select_all(action='SELECT') | |
bpy.ops.object.delete(use_global=False) | |
def generate(self): | |
for i in range(0,self.number): | |
x = randint(-3, 3) | |
y = randint(-3, 3) | |
z = randint(-3, 3) | |
mkObj = Monkey(location=(x, y, z)) | |
mkObj.add() | |
mkObj.modify() | |
# Cear Scene | |
scene = Scene(10) | |
scene.clear() | |
scene.generate() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment