Discussion:
[Maya-Python] Dynamically create and parent attribute with maya API
Daniele Dolci
2018-12-06 15:09:42 UTC
Permalink
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:

[image: 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+***@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.
Nicolas Combecave
2018-12-06 15:19:00 UTC
Permalink
On a vanilla blendshape node, I believe blendShape1.weight is a multi
attribute, and blendShape1.weight[0] has an alias named pSphere1
Post by Daniele Dolci
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
[image: 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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/ef181407-1a77-4c5b-93f1-1c1e02ecdb1d%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/ef181407-1a77-4c5b-93f1-1c1e02ecdb1d%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAD65uqmtw%2BpoA8squYMiLzb8xKw3Pur_YsL50HM0%3DmYVZvpUAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Daniele Dolci
2018-12-06 21:54:17 UTC
Permalink
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!
Post by Nicolas Combecave
On a vanilla blendshape node, I believe blendShape1.weight is a multi
attribute, and blendShape1.weight[0] has an alias named pSphere1
Post by Daniele Dolci
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
[image: 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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/ef181407-1a77-4c5b-93f1-1c1e02ecdb1d%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/ef181407-1a77-4c5b-93f1-1c1e02ecdb1d%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/04fa3f79-048c-4451-a2c5-7b05b062b75e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...