Re-Create nConstraints by API

66 views
Skip to first unread message

David Lantos

unread,
Jan 15, 2018, 1:31:39 PM1/15/18
to Python Programming for Autodesk Maya
Hi Guys!

I'm doing a reasearch how can nConstraints be recreated by api. I've found nConstraints don't have a solid data structure.

Here is, approximately, how nodes are connected:
mesh1 -> nCloth1 -> nComponent1 -> dynamicConstraint.ids[0]
mesh2
-> nCloth2 -> nComponent2 -> dynamicConstraint.ids[1]

The nConstraint gets NId data type. I checked the api's doc but It looks like a black box.

The question is, do anybody have any ideas how can I get the component ids are used by constraints?

Marcus Ottosson

unread,
Jan 15, 2018, 2:05:34 PM1/15/18
to python_in...@googlegroups.com

Something I typically do when trying to figure out how to populate some undocumented data member is to look at how Maya Ascii does it.

For example..

...
createNode dynamicConstraint -n "dynamicConstraintShape1" -p "dynamicConstraint1";
...
connectAttr "dynamicConstraintShape1.evs" "nucleus1.is[0]";
connectAttr "dynamicConstraintShape1.evc" "nucleus1.ic[0]";
connectAttr "nComponent1.ocp" "dynamicConstraintShape1.cid[0]";
connectAttr "nComponent2.ocp" "dynamicConstraintShape1.cid[1]";
connectAttr ":time1.o" "dynamicConstraintShape1.cti";

This is everything related to the constraint itself, and..

...
createNode nComponent -n "nComponent1";
    rename -uid "5CA944EE-46C7-5933-6EF2-70B733AACB38";
    setAttr ".ct" 2;
    setAttr ".el" 2;
...
connectAttr "nComponent1.ocp" "dynamicConstraintShape1.cid[0]";
...
connectAttr "nClothShape1.nuid" "nComponent1.obid";
...
// End of temp.ma

These are everything related to the nComponent. From here you might be able to figure out how to replicate this with API calls.

David Lantos

unread,
Jan 15, 2018, 2:20:14 PM1/15/18
to Python Programming for Autodesk Maya
Sorry I did a bit mistake. I would like to store (like in json) the data used for creating nConstraint. What I actually need is the component ids per mesh.
I got NId from nComponent that seems useless for me. Is there any way to get component list from nComponent?

David Lantos

unread,
Jan 15, 2018, 2:30:22 PM1/15/18
to Python Programming for Autodesk Maya
Ok, meanwhile I just realized there is ".componentIndecies" attribute. Somehow it was hidden. Now I have everything to recreate. Thanks!


2018. január 15., hétfő 11:05:34 UTC-8 időpontban Marcus Ottosson a következőt írta:
Reply all
Reply to author
Forward
0 new messages