1
$\begingroup$

This question already has an answer here:

I have ply format mesh in edit mode in blender. When I select some vertices , I need the x y z coordinates to be printed as output. Is it possible?

$\endgroup$

marked as duplicate by ideasman42, VRM, Gwen, zeffii, Ray Mairlot May 3 '16 at 14:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ The mesh being imported from a PLY seems irrelevant to the question being asked. Perhaps the question should be How to print the XYZ coordinates of all selected vertices in edit-mode? Its also not clear if this is a single function you want to run, or if you want the select action to always print vertex locations. $\endgroup$ – ideasman42 May 3 '16 at 6:53
2
$\begingroup$

As ideasman42 wrote in his comment, this will work for any mesh in edit mode, regardless of whether it was imported from PLY or any other format, or generated within Blender:

import bpy, bmesh

bm = bmesh.from_edit_mesh( bpy.context.object.data )
mw = bpy.context.object.matrix_world 

selected_verts_coordinates = [ mw * v.co for v in bm.verts if v.select ]

print( selected_verts_coordinates )

This will only work for selected vertices when the mesh is in edit mode.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.