Python API question - moving vertices to world position based on vertex colors

680 views
Skip to first unread message

Paul Harris

unread,
Jan 18, 2017, 3:25:07 PM1/18/17
to Python Programming for Autodesk Maya


Hi all

i need to translate each the vertices of a selected object to the position in world space represented by their vertex color. So basically take RGB color and make it XYZ position for all the verts.  
I have this maya.cmds version that works fine, except it's massively slow on any geo with more than about 5000 vertices:

#-------------
import maya.cmds as mc

selObjs = mc.ls(sl=true)
myVerts = mc.ls('%s.vtx[:]' % selObjs[0], fl=True)

for vert in myVerts:

    col = mc.polyColorPerVertex(vert, query=True, rgb=True )
    mc.move(col[0], col[1], col[2], vert, rpr=1, ws=1)
#---------

Now i'm trying to figure out how to do this with openMaya to speed things up a bit, but having never used that Python API i'm having a bit of trouble.  

Seems i need to get the vert color list using getVertexColors then set the positions using setPoints, somehow needing to translate the MColorArray to an MPointArray...
Anyone have a simple way of doing this?

Cheers

Paul Harris

unread,
Jan 18, 2017, 10:12:37 PM1/18/17
to Python Programming for Autodesk Maya
never mind, think i've figured it out..
thanks anyway!

Marcus Ottosson

unread,
Jan 19, 2017, 3:51:06 AM1/19/17
to python_in...@googlegroups.com
Would it be possible to share your solution? :)

Best,
Curious cat

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8461d7c6-c220-4fb4-b5f9-f76f1509dba4%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Paul Harris

unread,
Jan 19, 2017, 3:35:33 PM1/19/17
to Python Programming for Autodesk Maya

Paul Harris

unread,
Jan 19, 2017, 3:36:46 PM1/19/17
to Python Programming for Autodesk Maya

Marcus Ottosson

unread,
Jan 20, 2017, 3:06:19 AM1/20/17
to python_in...@googlegroups.com
Thanks!

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.



--
Marcus Ottosson
konstr...@gmail.com

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Reply all
Reply to author
Forward
0 new messages