DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Blender 2.49 Display Mesh Vertex Information

03.29.2012
| 2870 views |
  • submit to reddit
        #!BPY
"""
Name: 'Print Mesh Data'
Blender: 245
Group: 'Mesh'
Tooltip: 'Print data.'
"""

__author__ = "Adrian Boeing"
__url__ = ["www.blender.org", "blenderartists.org", "www.python.org"]
__version__ = "0.1"
__bpydoc__ = """\
Print Mesh Data

Prints the data in the mesh
"""

# ***** BEGIN GPL LICENSE BLOCK *****
#
# Script copyright (C) Adrian Boeing
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------


import Blender

from Blender.BGL import *
from Blender.Draw import *
from Blender.Window import *
from Blender.Mesh import *
import BPyMessages
import bpy

def main():
    sce = bpy.data.scenes.active
    ob_act = sce.objects.active
    if not ob_act or ob_act.type != 'Mesh':
        BPyMessages.Error_NoMeshActive()
        return

    is_editmode = Blender.Window.EditMode()
    if is_editmode:
        print " "
        Blender.Window.EditMode(0)
  
        matrix = ob_act.getMatrix() #Py_Matrix space='worldspace'
        theMesh = ob_act.getData(mesh=1)
        for v in theMesh.verts: #MVert
            if v.sel == 1:
                print v
                vec = v.co #vector coordinates
                tvec = vec * matrix
                print tvec
                 
    Blender.Window.EditMode(1)
if __name__ == '__main__':
	main()