View Full Version : Custom Maya object Sets

08 August 2006, 10:55 PM
I have being trying to create a custom object set using the Maya API, but it seems a little odd. For a start most of the static attributes seem to be missing - eg dagSetMembers - so I don't think it will connect up properly anyway. Also it doesn't appear as a DAG node.

However I am guessing this is how the Mental Ray textureBakeSet and vertexBakeSet nodes work, and they have no problems.

Rob Bateman seems to have had problems too going by this Highend3d post .

Does Rob or and Mental Ray people (MasterZap??) have any more information on how to get this working in Maya 7 on Linux?



Robert Bateman
08 August 2006, 01:21 AM
sets are not Dag nodes, they will only ever be dependency nodes (only shapes and transforms are DAG objects). The big question really is *why* do you want a custom object set?

the attributes are all there (just checked the header file). They will of course be hidden in the GUI, but thats another story. listAttr should display them....

It's not so much that i had a problem creating a custom set, it's just that it seemed to be largely pointless to me since they never worked with the mel sets command.

I came to the conclusion that they are more hassle than they are worth, since it seems that you can only seem to do anything with them with connectAttr/setAttr & getAttr. Alternatively you could write your own sets command, but that seems an awful lot of effort for not a lot of gain imo.

I personally gave up on the idea and just used the normal objectSet nodes, with extra attr's added to them with via the addAttr mel command (setting the "annotation" attr to something to distinguish your type of sets from the other object sets).

The only reason i can see as to why you'd ever want a custom set is to be able to use Compute() to do something clever with the data, in which case I'd suggest something along the lines of :

* Create a custom MPxNode, and add a message attr called "set" or something to that effect, and connect it to the "message" attr of a normal objectSet, which you can use the sets command on to manage the data in it.
* setMPSafe(false) within the postConstructor
* Within the compute, use thisMObject() to bind the node to a function set. Find the MPlug for your "set" attr, get the objectSet node connected to it. Now grab the data from that objectSet node (you should be able to use MFnSet to grab the data).

That's basically the way i ended up tackling the problem anyway.....

However I am guessing this is how the Mental Ray textureBakeSet and vertexBakeSet nodes work, and they have no problems.

yeah, they are listed in the DG node & attr reference as being inherited from bakeSet, which is inturn derived from kSet. Since MentalRay is not a plugin or a module, i suspect it can get around those problems in the same way that character Sets and shading engines do. I suspect though, that the sets command is implimented with MFnSet, which inturn can only be bound to kSet based nodes, as apposed to kObjectSet nodes. Which is slightly annoying.
I have noticed that MPxObjectSet is the only MPx class without an devkit sample.

(nice website btw)

08 August 2006, 10:45 AM
True - there isn't much point in a custom set beyond cosmetics ;) I do not have a fancy compute method.

I think I have worked out what I was doing wrong. In the registerNode() method I had not put MPxNode::kObjectSet at the end as the type so it was defaulting to a normal dependancy node. This also seems to be why it didn't inherit the attributes from the objectSet class (they weren't appearing with listAttr).

I have just tried it and it seems to work with the sets MEL command no problem now - you can add objects, do unions and intersections etc.

I am not that good at the Maya API yet so I didn't realise I needed to do this! I guess you don't need to if you are just inheritting from MPxNode.


CGTalk Moderation
08 August 2006, 10:45 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.