values of vertex X Y Z

i werote a little script
like this to get the values of each vertex i a mesh but i also
want to get the X Y Z values in local and global mode

how can i do that?


me = B.Mesh.Get( ob.data.name )
print 'me  name =',me
# print out the verts, edges and faces of our mesh
print
print 'Vertices'
print
for vert in me.verts:
   print  "X value ",verts.pt1[0]
   

 

trhe last line for Pt1 is giving an erroe and don’t know how to corect this
any help is appreciated a lot
Thanks

Try reading over this and see if it helps:


import Blender
import bpy

scn = bpy.data.scenes.active
obName = 'Whatever Object You Want'
ob = [o for o in scn.objects if o.name == obName][0]

omat = ob.getMatrix()
me = ob.getData(mesh = True)

#Print Out Local Coordinates
print """============================
=========Local==============
============================"""
for v in me.verts:
    print 'X:%f, Y:%f, Z%f' %(v.co[0], v.co[1], v.co[2])
    
#Print Out Global Coordinates
print """============================
=========Global=============
============================"""
for v in me.verts:
    newCo = v.co * omat
    print 'X:%f, Y:%f, Z:%f' %(newCo[0], newCo[1], newCo[2])

Also note that vertexes are accessed by mesh.verts[n].co[i], where n ranges between zero and the number of vertexes in the mesh minus 1 and i ranges between 0 and 2, representing X, Y, and Z, respectively.

what does the omat = ob.getMatrix() represent
this matrix has something to do with the global but what is the relationship?
any good doc on this >

so the M transorm shows the local and normally you get the local vertex not the global one
and if global are needed you got go through the matrix to get it
if i understand well this idea

made test with it
but got an erroe

list index on line 6 is out of range ?
how to correct this?

Thanks

omat is the matrix of the object. When you transform the local vertexes by it (i.e. multiply), then you get global coordinates.

For the Error: Make sure you’ve changed obName variable so its actually the name of the mesh type object you want to get.

ok i transfered some lines to my little script and it’s beginning to work

now the object i have is in top view - a plane modified

the value i get in the list for vertices don’t seems to correspond to the values in the n transform
any reason for this?

by the way i’m hoping to make a little script to extend some of the vertex then apply a new faces to theses new vertices
don’t know if this can be done easily - hope so
i could show you one of the plane shape but i would have to show it in basic
where i already ahve a post there - you might better understand the task i;m trying to do in automaticaly with script for outside verteices not the inside one hopefully

let me know if you want to see the pic of objects

Thanks

For the n-transform panel, make sure you’re switching between global and local, they should be the same.

Are you basically trying to code an extrude function?

But Not For All The Vextex Only Thoses That Are On The Outside of the object

don’t knoe if there is an existing script for this ?

and I’m Not Certain That I Can Be Done easily
but i’m looking and checking with your gurs if thiis can be done!

i’n trying to do some hieroglyph carved in or out
so there are 100’s of symbols and logograms to be done
before i can begin doing some fresco style hieroglyph

i began a wip here

http://blenderartists.org/forum/showthread.php?t=135309
you can see some pic of lgogram in 3 D that i did manually but this is a lot of work
and would help with a script that would do some of the work at least to save some time

Salutations