# This popped out...

I’ve been trying to learn some python scripting and I’ve been messing around with a bit of mesh editing. Somehow created a script that did this to a cube. Looks kinda floral… Do you think I should try and do something with it? (Maybe put it in a scene somehow?)

I think you should continue with that script! I like it very much! Make it take inputs…

Reminds me of RorbertT’s floribundus, any insight on the technique that created this effect?

Funny, it reminded me of floribundus too. Okay, basically what I did is I made a script that creates vertices at the center of every face. I then took those vertices and scaled them up and ran the script again and ran the script and scaled…etc. until I got that. I’ll probably work on integrating my procedure into the script soon.

Here’s the function so far.

``````
def AlternateFaces(mesh,p):
while p&gt;0:
p = p-1
#mesh.verts = []
list = []
for face in mesh.faces:
l = len(face.v)
n = 0
x = 0
y = 0
z = 0
for vert in face.v:
n = n+1
x = x + vert
y = y + vert
z = z + vert
avx = x/n
avy = y/n
avz = z/n
newvert = Vert(avx, avy, avz)
mesh.verts.append(newvert)
if l == 3:
f1 = face.v
f2 = face.v
f3 = face.v
newface1 = Face([newvert, f1, f2])
newface2 = Face([newvert, f2, f3])
newface3 = Face([newvert, f1, f3])
list.append(newface1)
list.append(newface2)
list.append(newface3)
if l == 4:
f1 = face.v
f2 = face.v
f3 = face.v
f4 = face.v
newface1 = Face([newvert, f1, f2])
newface2 = Face([newvert, f2, f3])
newface3 = Face([newvert, f3, f4])
newface4 = Face([newvert, f4, f1])
list.append(newface1)
list.append(newface2)
list.append(newface3)
list.append(newface4)
mesh.faces = list
NMesh.PutRaw(mesh, name)

``````

Yeah, I’m pretty new to python(coding in general) so I’m not sure how to write a gui or anything. (not that this function deserves one at this stage)

Doesn’t work for me… LOL. Forgot to add the top lines. I’m busy workingon a number of arbitrary functions at the same time in the same text file and this is what I put at the top of it. Sorry about that. :-?

``````
#Modules etc.
import Blender
from Blender import NMesh, Object
from Blender.NMesh import Vert, Face
from Blender.Draw import *
from Blender.BGL import *
from math import *
import random

#Vars
o = Object.GetSelected()
data = o.data
name = data.name
mesh = NMesh.GetRaw(name)

``````

oh, and also remember to actually run the function:

``````
AlternateFaces(mesh, 1)

``````

Sorry about the double-post. Here it is fully automated, with everything you need.

``````
import Blender
from Blender import NMesh, Object
from Blender.NMesh import Vert, Face
from math import *
import random

o = Object.GetSelected()
data = o.data
name = data.name
mesh = NMesh.GetRaw(name)

#Spikes out the mesh
#mesh is the mesh you want to work on
#p is the number of times to protrude
#t is the scaling factor of the protruded vertices
def AlternateProtrusions(mesh,p,t):
while p&gt;0:
p = p-1
list = []
freshlist = []
for face in mesh.faces:
l = len(face.v)
n = 0
x = 0
y = 0
z = 0
for vert in face.v:
n = n+1
x = x + vert
y = y + vert
z = z + vert
avx = x/n
avy = y/n
avz = z/n
newvert = Vert(avx, avy, avz)
mesh.verts.append(newvert)
freshlist.append(newvert)
if l == 3:
f1 = face.v
f2 = face.v
f3 = face.v
newface1 = Face([newvert, f1, f2])
newface2 = Face([newvert, f2, f3])
newface3 = Face([newvert, f1, f3])
list.append(newface1)
list.append(newface2)
list.append(newface3)
if l == 4:
f1 = face.v
f2 = face.v
f3 = face.v
f4 = face.v
newface1 = Face([newvert, f1, f2])
newface2 = Face([newvert, f2, f3])
newface3 = Face([newvert, f3, f4])
newface4 = Face([newvert, f4, f1])
list.append(newface1)
list.append(newface2)
list.append(newface3)
list.append(newface4)
g = 0
x1 = 0
y1 = 1
z1 = 0
for vert in freshlist:
x1 = x1 + vert
y1 = y1 + vert
z1 = z1 + vert
g = g+1
avx1 = x1/g
avy1 = y1/g
avz1 = z1/g
for vert in freshlist:
dx = vert - avx1
dy = vert - avy1
dz = vert - avz1
vert = vert + t*dx
vert = vert + t*dy
vert = vert + t*dz
mesh.faces = list
NMesh.PutRaw(mesh, name)

#eg.
AlternateProtrusions(mesh,5,0.5)
#Protrudes five times in succession, scaling by 1.5 each time
#Try negative values for t as well

``````

Working nicely. I’ll have to experiment a bit more with it when I have more time at hands.
But it works right out of the box, didn’t give me any errors (at least not once I selected an object) and it’s really easy to understand. Thanks a lot!

I’m glad it works. Thanks for the feedback.
Any ideas on how to embroider it a bit?