python help

ok…i have a problem with my script.when i want a print of the empty.LocX(for ex) it shows a huge number on the DOS window like 2.013456006009(say) which is too perfect.but i don’t want that.i just want to work with 3-4 place of decimal approximation which will be 2.013 here.does anybody know how to do it?another problem:i want to get the vertices which are selected to be recognised by the script…like —Object.GetSelected().is there any way to do this?

For your first problem, you can use the function called round.


# little example

import Blender

ob = Blender.Object.GetSelected()
if ob:
        print round(ob[0].LocX, 3)

which would return: 2.013 in your case.

the arguments for round are: the number to round, the number of decimals.

For your other question, I don’t think there’s a way to get the selected vertice, although I think you can get the selected face (Blender.NMesh.GetSelectedFaces) or something like that.

Martin