New Blender Primitive: N-Pyramid

Hello everyone!
I’m around here again…

I’ve created a simple script to create a pyramid with any number of sides from 3 to 100. It’s quite easy and self-explanatory.

I’d be glad to hear comments, suggestions, ideas, etc.

Here’s the script: http://svn.icetempest.com/blender/pyramid/trunk/ls_pyramid.py

And a little screenshot:
http://www.icetempest.com/wp-content/uploads/2009/06/npyramid.png

Regards,

  • Sergio Moura

very nice beginning

i was looking for something like this for a long time and thinking about making one

the only thing that would improve nicely on this would be to have some
stones with joint on each course and theses should be stagerred
hope you can add this feature

alos i would suggest o include some sort of material
if you don’t well i’ll’ do it myself it’s not a major requirement

another thing that might usefull would be a width for the base!
like 100 meters or 230 like the chaops pyramide
and may be an angle to go up
don’t know know i you could include this ?

keep up the good work

Happy blendering

Thank you for your comments!
I’d like if you could clarify what you mean by “to have some
stones with joint on each course and theses should be stagerred”.
I can’t quite figure out what you meant… Maybe some visual help?

“another thing that might usefull would be a width for the base!
like 100 meters or 230 like the chaops pyramide”
That… could be easily calculated. You want to change the “step width” parameter for a “base width”? Maybe I can make another primitive script with another input values…

“and may be an angle to go up” this seems like a nice idea. You mean an angle for the step? Like it’s currently 90 degrees and it would go from “1” to “179”?

I’d be happy to include the features (once I understood them all).

“alos i would suggest o include some sort of material” – In the script?? Or provide a .blend file with it? I guess I can do it over the weekend =)
Or, if you (or anyone else) would like to create a sample .blend file with textures using this script, I’d like very much to have it (and have the rights to distribute it in my website).

Regards,

  • Sergio

may be you where not thinking about this example

but let’s take the best example the pyramid of cheops in Egypt

it has a base of 230 meters 4 sides

now the sides of the pyramid are at a certain angle around 52 degrees

and there are the number of steps or courses
assuming that each course has as constant height or thickness

so one way to do it would be to specify the base in meters then the numbers of courses
and the angle i guess

i can show a pic of it but i’m certain you can find one on wikipedia

and for the stones look at the pic of cheops each course on the outside is made up individual stones with joints between them
and the stone on the next course are offseted conpae to the other courses below and above

i hope it clarifies what i meant

Happy blendering

I guess I’ve done what you wanted. I’m very pleased with the result. I hope you’ll like it…

Ok! I understood that one… This is on my TODO list, for another script that will generate only 4-sided-pyramids. Hold your breath for a week-or-so, and I’ll post the other script here. I’m already working on it, but this is being tough.

The link is the same: http://svn.icetempest.com/blender/pyramid/trunk/ls_pyramid.py

I’ve added a new feature (side angles). I know it’s not realystic, but you can make some interesting variations.

Let me know if you make that material.

Regards,

  • Sergio

here is an example for coding the mat and color


import Blender
from Blender import *
def makeCube(x,y,name,passedMesh,passedScene):
ob = Object.New("Mesh",name)
ob.LocX=x
ob.LocY=y
 
ob.link(passedMesh)
passedScene.link(ob)
return ob
 
#Create materials.
localScene = Scene.GetCurrent()
matRed = Blender.Material.New('matRed')
matRed.rgbCol = 1,0,0
matBlue = Blender.Material.New('matBlue')
matBlue.rgbCol = 0,0,1
 
#Create cubes.
redMesh = Mesh.Primitives.Cube(1)
redCube = makeCube(0,0,"redCube",redMesh,localScene)
redMesh.materials = [matRed]
blueMesh = Mesh.Primitives.Cube(1)
blueCube = makeCube(2,0,"blueCube",blueMesh,localScene)
blueMesh.materials = [matBlue]
mixedMesh = Mesh.Primitives.Cube(1)
mixedCube = makeCube(4,0,"mixedCube",mixedMesh,localScene)
 
#Lets add two materials to this mesh.
mixedMesh.materials = [matRed, matBlue]
 
#Manually assign faces a material index. (We know the cube has 6 faces i.e. 0-5).
mixedMesh.faces[0].mat = 0 #Face #0 gets index #0 which is Red.
mixedMesh.faces[1].mat = 1 #Face #1 gets index #1 which is Blue.
mixedMesh.faces[2].mat = 0
mixedMesh.faces[3].mat = 1
mixedMesh.faces[4].mat = 0
mixedMesh.faces[5].mat = 1
Redraw(-1)
 
 
 

here the site for this

http://blenderartists.org/forum/showthread.php?t=131745&highlight=python+beginer

note

when you make a new version always add a number at the end of name for new script

like pyr1.py so that that you don’t erase any old verison of the script just in case
hope it helps

Oh! You want me to create an object in the script itself? What if someone wants to create an exotic pyramid and I end up adding some unwanted material to the current scene… I guess it wouldn’t be nice…

Also, about the versions… The link i provided in an SVN repository. Anyone can grab any version at any time. Just use a program like subversion, tortoise SVN (windows) or rapidsvn(linux)…

Regards,

  • Sergio

ounce you have a default material and color

you can always change it for another mat or color

it’s very easy to do!

it’s just that you don’t end up with a object with no color or mat
but as i said it is a nice feature to have it’s not a major thing
only a suggestion for something nice!

Thanks