How to set objectGrpCompList on instances via OpenMaya API

25 views
Skip to first unread message

Oliver Pedersen

unread,
Sep 17, 2021, 1:35:12 AM9/17/21
to Python Programming for Autodesk Maya
I generated some instances via OpenMaya API but the connections to the shader are not automatically created. For the case where this is a single shader assigned to the whole object I can connect the instObjectGroups attribute to the shading engine node and everything is great.

I'm running into an issue when I have two shading engines attached to the original geo. I have tried to recreate the connections I see when I duplicate special through the menu, by adding a new groupId node and copying the objectGrpCompList data from the first instance of the shape. I must be doing it wrong, because the shader is not working in the viewport. When I save and re-open the Maya scene without changing anything, the shader is displayed in the viewport correctly, so Maya must be fixing something for me automatically when it opens again. 

I used MFnComponentListData to get the faces and set them manually on all the corresponding objectGrpCompList. I can verify with a get that they are correct, but not sure if it's actually the proper way to set them based off this post from many years ago. https://forums.cgsociety.org/t/objectgroups-groupid-and-multi-shader-assignment/1213536/4

I cannot figure out how to do what is in the example they posted with MFnMeshData. If anyone could give an explanation how to achieve this it would be great. Thank you!
Reply all
Reply to author
Forward
0 new messages