PutRaw headache!!

(BlendedRace) #1


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
#end of the file

THe error is:
File “<string>”, line 20
SyntaxError: invalid syntax

Cheers Stephen

(eeshlo) #2

NMesh.PutRaw is part of the Blender module, so you either call it like this:

eachmesh = Blender.NMesh.GetRaw.each.data.name)



OR you add this at the start of the script:

from Blender import NMesh

(rndrdbrian) #3

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?


(BlendedRace) #4


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.

Cheers Steven

(eeshlo) #5

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.

(BlendedRace) #6

:smiley: THANKS :smiley: THANKS :smiley: THANKS :smiley:

It was something so b****y obvious as tab errors, The line above putraw was one level up, so the subroutine didn’t work correctly.

I usually write in IDLE (where I’d pick that up!!).

Thanks for your help.

I’m currently debugging the quad splitting support in the ASE export script, then will release it on my webpage.


Thanks Steve!!