Layout: scripting, + use Menu->Window->Toggle System Console to debug errors

 

Turn on numbering, line wrap and code highlighting in the editor.

 

Initialization libraries to import:

 

import bpy

from bpy import context

from math import sin, cos, radians, pi

 

 

Cursor position and cube object initialization:

 

 

cursor = context.scene.cursor_location

cubeobject = bpy.ops.mesh.primitive_cube_add # create new cube and use console to get cube creation code

 

Test cursor + cube code:

cursor.x = cursor.y = cursor.z = 3 # init cursor position

bpy.ops.mesh.primitive_cube_add(radius=1,

 view_align=False, enter_editmode=False, location=(cursor.x, cursor.y,

cursor.z), layers=(True, False, False, False, False, False, False,

False, False, False, False, False, False, False, False, False, False,

False, False, False)) # spawn cube at position

 

# The same cube code:

bpy.ops.mesh.primitive_cube_add(location=(cursor.x, cursor.y, cursor.z))

 

 

 

Array of cubes around cursor with scaling:

 

dist_rad = 3.0

theta = 0.0

 

while theta < 2*pi:

    x = cursor.x + dist_rad * cos(theta)

    y = cursor.y + dist_rad * sin(theta)

    z = cursor.z

    cubeobject(location=(x,y,z))

 

    bpy.ops.transform.resize(value=(0.5, 0.5, 0.5)) # scale size of each selected cube

 

    theta += (pi/4)

 

 

 

 

  • Нет меток