Dynamically create and parent attribute with maya API

43 views
Skip to first unread message

Daniele Dolci

unread,
Dec 6, 2018, 10:09:43 AM12/6/18
to Python Programming for Autodesk Maya
Hi, 

I am creating as excercise a blendshape node inheriting from the MPxDeformerNode. I got it to work with 1 mesh as input, now I want to make it work with n inputs. I don't understand how to dynamically create attribute whose name is the name of the target. I mean if we have a maya blendshape, that is how it looks: 

bs.JPG

But when you then access the pSphere2 attribute you don't need to do blendShape1.weight.pSphere1 but simply blendShape1.pSphere1.

If I query the type of the attribute weight it is a TDataCompound. 

I guess this is something that does not need to happen in the initialize of the plugin but rather creating a command that handles it in the doIt, redoIt etc and having some methods like addTarget and so on, right? If anyone could share some snippet or a little explanation on how to do it would be really appreciated!

Thanks,
Daniele

Nicolas Combecave

unread,
Dec 6, 2018, 10:19:18 AM12/6/18
to python_in...@googlegroups.com
On a vanilla blendshape node, I believe blendShape1.weight is a multi attribute, and blendShape1.weight[0] has an alias named pSphere1


--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/ef181407-1a77-4c5b-93f1-1c1e02ecdb1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniele Dolci

unread,
Dec 6, 2018, 4:54:18 PM12/6/18
to Python Programming for Autodesk Maya
Hi,

Thanks for the reply, I tried by createing a float attribute with the API (MFnNumericAttribute) and set it to array and also set to keyable, to make it appear in the channel box, but the attribute I created did not get the indexing typicla of array, it is just a normal float. Could you make a small snippet of code to show how to implement it with api? Thank you! 


Il giorno giovedì 6 dicembre 2018 16:19:18 UTC+1, combi ha scritto:
On a vanilla blendshape node, I believe blendShape1.weight is a multi attribute, and blendShape1.weight[0] has an alias named pSphere1


Le jeu. 6 déc. 2018 à 16:09, Daniele Dolci <daniele...@gmail.com> a écrit :
Hi, 

I am creating as excercise a blendshape node inheriting from the MPxDeformerNode. I got it to work with 1 mesh as input, now I want to make it work with n inputs. I don't understand how to dynamically create attribute whose name is the name of the target. I mean if we have a maya blendshape, that is how it looks: 

bs.JPG

But when you then access the pSphere2 attribute you don't need to do blendShape1.weight.pSphere1 but simply blendShape1.pSphere1.

If I query the type of the attribute weight it is a TDataCompound. 

I guess this is something that does not need to happen in the initialize of the plugin but rather creating a command that handles it in the doIt, redoIt etc and having some methods like addTarget and so on, right? If anyone could share some snippet or a little explanation on how to do it would be really appreciated!

Thanks,
Daniele

--
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.

Daniele Dolci

unread,
Dec 7, 2018, 2:55:20 AM12/7/18
to Python Programming for Autodesk Maya

Basically I managed to creare the floatArray Attribute and assign aliases, but then I am not sure how to make those appear in the channel box, setKeyable to true is not enough... Any Hint?

attr_cb.JPG

Reply all
Reply to author
Forward
0 new messages