Extruding faces via python?

I’m in a bit of a pickle figuring out how to extrude faces using python scripting. - At the moment I have a blender script which creates the tooth profile of a chain driven sprocket:

http://img.photobucket.com/albums/v294/renderedbrian/testwip2.jpg

I’d like my script to be add “thickness” to the tooth profile, so that all that will be required for the end user is to spin dup + remove doubles (or use array modifer) to build a sprocket. (the top sprocket above I extruded by hand)

I can’t find anything in the python API which looks like it will “extrude” my mesh. Is it possible using python to make blender go into “edit” mode, then “simulate” a keypress for extrude?

thanks in advance


Brian

theres no way to do this without manualy making your own function.

btw- have you tried using the array modifier for making gears/cogs? it does a good job.

it’s not really that hard if you have a basic vertice arrangement. i.e. if you want a cube, it could be scaled like this:

#parameters in ui: scalex scaley scalez locx locy locz
v0 = [locx - scalex, locy-scaley, locz-scalez]
v1 = [locx - scalex, locy+scaley, locz-scalez]
etc…
#this would make the scale parameter, be the distance of the verts from center (kinda) and the center would be at locx,locy,locz

#then just make the lists
verts = [v0, v1,v2,v3,v4,v5,v6,v7]
faces = [[0,1,2,3][4,5,6,7][0,4,7,3][1,5,4,0][1,5,6,2][2,6,7,3]]

#and append
somemesh.extend(verts)
somemesh.extend(faces)

… you get the picture, if you have questions or need help email me or post, I think this’d be very usefull, I’d be glad to help.

edit: looking at your ui: you might want to make “teeth:N” be an integer, if they put in 20.5 it might break something…

Ideasman, that is what I am planing. My script will make the correct sprocket tooth profile, add an empty, then the end user will just have to add an array modifier to have a nice geometrically correct sprocket

:slight_smile:


Brian

I think I’ve got it figured out in my head how to “extrude” - won’t know till I sit down and try the code to see if it will work. Hopefully later on this afternoon I should have it working.

Good point about teeth:N being an integer! :o