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…
http://img25.echo.cx/img25/666/wierd2hk.th.jpg
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>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[0]
				y = y + vert[1]
				z = z + vert[2]
			avx = x/n
			avy = y/n
			avz = z/n
			newvert = Vert(avx, avy, avz)
			mesh.verts.append(newvert)
			if l == 3:
				f1 = face.v[0]
				f2 = face.v[1]
				f3 = face.v[2]
				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[0]
				f2 = face.v[1]
				f3 = face.v[2]
				f4 = face.v[3]
				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… :expressionless:

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()[0]
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()[0]
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>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[0]
				y = y + vert[1]
				z = z + vert[2]
			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[0]
				f2 = face.v[1]
				f3 = face.v[2]
				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[0]
				f2 = face.v[1]
				f3 = face.v[2]
				f4 = face.v[3]
				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[0]
			y1 = y1 + vert[1]
			z1 = z1 + vert[2]
			g = g+1	
		avx1 = x1/g
		avy1 = y1/g
		avz1 = z1/g
		for vert in freshlist:
			dx = vert[0] - avx1
			dy = vert[1] - avy1
			dz = vert[2] - avz1
			vert[0] = vert[0] + t*dx
			vert[1] = vert[1] + t*dy
			vert[2] = vert[2] + 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. :smiley: Thanks for the feedback.
Any ideas on how to embroider it a bit?