I’m trying to halve the height of my meshs using python (Its for export to a game which doesn’t recognize SizeZ) so I’m cycling through the vertices and halving the Z values.
Can anyone explain why I keep getting an error with PutRaw.
mport Blender
import sys
print "-------------------------------"
#Get the object data
allobjects = Blender.Object.Get()
for each in allobjects:
if each.Layer == 1:
print each.name
eachmesh = NMesh.GetRaw(each.data.name)
mv = eachmesh.verts
for x in range(len(mv)):
coords = eachmesh.verts[x].co
oldz = coords[2]
coords[2] = coords[2] / 2
print oldz, coords[2]
obname = eachmesh.name
NMesh.PutRaw(eachmesh,obname)
Blender.Redraw()
sys.stdout.flush()
#end of the file
THe error is:
File “<string>”, line 20
NMesh.PutRaw(eachmesh,obname)
^
SyntaxError: invalid syntax
Sillyseat, i’m not sure that what you are trying to do would work.
If you havled the z position of each vertex, the Z Sizr would still be the same, so, if Z Size = 0.5, and you halfed each vertex z position, then
you would have quartered the effective size of the mesh.
Have you tried applying the size / rot with control A?
Thanks for the replies. I wasn’t very clear. The objects are a track to be exported to Racer (http://www.racer.nl) using a ASE export script I’ve updated. The script and racer engine don’t appear to use the transformation data so using SizeZ is of no use.
I’m making a loooong track, but have found it is too hilly. The track surface and surrounds are now split into about 380 separate objects so I was trying to make a script to automatically halve the Z values of each vertex, thus reducing the hilliness of the track.
I’ve tried it wth from Blender import NMesh and NMesh.PutRaw etc and with import Blender and Blender.NMesh.PutRaw etc and I always get an error at PutRAw.
You might have done something like mixing spaces and tabs?
If you do that, python can get confused, while it looks the same to you, it doesn’t for Python.
If the code you displayed was directly cut&pasted from your actual code, than it appears that all but the NMesh.PutRaw() line use spaces, and NMesh.PutRaw uses tabs.
Use either one or the other, don’t mix both.