[Maya-Python] Color set types

2018-06-29 Thread Alexander Berx
Hi all,

I'm writing a script for generating rest position color sets. I first wrote 
a version using Maya cmds but since it was a bit slow I did a rewrite using 
the Maya api.
Everything is working but when I create a colorset using the api it's 
always of the type RGBA however I would need RGB.

I just create the colorset like this:

dag_path = OpenMaya.MDagPath()
sel_iterator.getDagPath(dag_path)

mesh_fn = OpenMaya.MFnMesh(dag_path)

mesh_fn.createColorSetWithName('rest')


There isn't any option for the type I can see in the api. Does anybody have 
an idea how this could be achieved?

Thanks in advance!


Cheers,
Alexander

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/87d2af0d-3396-434c-8b2b-77733d81f5da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: [MPlug] error on get attribute

2018-06-29 Thread Cedric Bazillou
oh i know pretty much every part of the api related to animation / rigging.
Im just pointing out that in order to use the API in python you have to 
follow some strict procedure ( automatic binding with swig)

import maya.OpenMaya as OpenMaya
def getMObject(nodeName):
selList = OpenMaya.MSelectionList()
OpenMaya.MGlobal.getSelectionListByName(nodeName,  selList)
depNode = OpenMaya.MObject()
selList.getDependNode(0, depNode) 

return depNode


nodeFn = OpenMaya.MFnDependencyNode(getMObject('joint1'))
matrixPlug = nodeFn.findPlug('rotatePivot')

for childIndex in range(matrixPlug.numChildren()):
print matrixPlug.child(childIndex).asFloat()


Hence me getting a plug from dependency Mfn function set and not fiddling 
with the MSelectionList ( which conceptually is for dag/dependency and 
components).
Most of the time when working with python programmer, or other artist i 
have to point out that the api is exposed and use some python syntax but 
you must adopt maya philosophy ( so asking for more pythonic doesnt make 
sense  : at some point
you will write it in c++ and your python code will be a waste of time to 
translate back to pure API)

Le jeudi 28 juin 2018 17:05:19 UTC+1, Rémi Deletrain a écrit :
>
> I want to get a vector attribute like *translate*.
> Attribute *translate* and *rotatePivot* is a same type. But get 
> rotatePivot doesn't work and get translate works fine.
>
> from maya import OpenMaya
>
> def get_mplug(s_attr_node):
> m_sl = OpenMaya.MSelectionList ()
> m_sl.add (s_attr_node)
> mp = OpenMaya.MPlug ()
> m_sl.getPlug (0, mp)
> return mp
>
> try:
> mp_translate = get_mplug("joint1.translate")
> print mp_translate.child(0).name()
> print mp_translate.child(1).name()
> print mp_translate.child(2).name()
> except:
> print "Get translate doesn't works"
> else:
> print "Get translate works"
>
> try:
> mp_rotate_pivot = get_mplug("joint1.rotatePivot")
> print mp_rotate_pivot.child(0).name()
> print mp_rotate_pivot.child(1).name()
> print mp_rotate_pivot.child(2).name()
> except:
> print "Get rotatePivot doesn't works"
> else:
> print "Get rotatePivot works"
>
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/9510eb6d-579a-4cdd-9992-54bd53158ce3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.