[EMS Discuss] Python scripts and Blender

Rick Osgood rick at richardosgood.com
Fri Apr 20 22:51:28 PDT 2012


If you enjoy making 3d models programatically then you should look into
openScad. It's free and it's designed for exactly that. people use it to
generate stl files for the MakerBot
On Apr 20, 2012 10:04 PM, "John Burridge" <burridge.john at gmail.com> wrote:

> Here's another Python script.  It uses sin and cos functions to place
> meshes onto a sphere... I'm not sure why I'm not using divisions of pi
> in it, but it works.
>
> ==============
>
> # Nov-23 2010
> # Script to make a cloud of mesh items (in this case cubes)
> #
>
> import bpy   # You have to import bpy calls or you can't script primitives
> import math # You have to import cmath calls to do sine and cosine
> functions
>
> #
> # phi should be the XY plane, theta should be the YZ plane
> #
> theta = phi = x = y = z = 0   #  defining x y and z by assigning a value
> step = 1  # 1 = really smooth shapes. Larger numbers give chunkier shapes
> lobe = 5  # fiddle with lobes to get different patterns. 5 gives star
> patterns.  .33333 gives a cool loop.
>
> while theta < 360:
>    x = 10 * math.cos(theta) * math.sin(phi)
>    y = 10* math.sin(theta) * math.sin(phi)
>    z = 10 * math.cos(phi)
>    bpy.ops.mesh.primitive_cube_add(view_align=False,
> enter_editmode=False, location=(x, y, z), rotation=(phi, 0.0, theta))
>    phi = phi + (step * lobe)
>    theta = theta + step
>
> ==============================
>
>
> --
> ----
>
> John Burridge
> burridge.john at gmail.com
> http://johnburridge.blogspot.com
> _______________________________________________
> Discuss mailing list
> Discuss at eugenemakerspace.com
> http://eugenemakerspace.com/mailman/listinfo/com.eugenemakerspace.discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://eugenemakerspace.com/pipermail/com.eugenemakerspace.discuss/attachments/20120420/5f2f30a3/attachment.html>


More information about the Discuss mailing list