I don't see using connections as inelegant at all. Actually, it's the cleanest and most reliable way to manage many relationships and associations in Maya. It's a manifestation of Maya's core architecture and its main strength. If you look at the way Maya's default nodes work together, or the way mental ray is implemented you'll see the same thing. The benefit is, as Chad suggests, that you don't have to worry about what the node is called - whether it moves around in the DAG, changes name through the UI, or the containing file becomes a reference - as long as the connection is maintained, your relationship is intact and management of that relationship is in Maya's hands. As soon as you start tracking nodes and relationships by name you take on the responsibility of reproducing what Maya already does, which in turn means you will need to generate and maintain a whole new layer of code.
We use a lot of message connections in our system and it is very reliable. It's so reliable that I can't remember what the connection tracing code looks like because it requires so little maintenance. It's been in place for around three years, since we started the company, and has not changed much. -Judah On Tue, Jan 12, 2010 at 10:12 PM, John Patrick <[email protected]> wrote: > Thanks Chad. I guess I'm doing a little wishful thinking here. If that > unique id was easily accessible, this might work but without it I suppose > messages are still the way to go. Onward and upward... > > On Tue, Jan 12, 2010 at 9:30 PM, Chad Dombrova <[email protected]> wrote: > >> you could pickle to a string and then add that to a string attribute on >> the node. the advantage of .messages is that if a node is moved in the DAG >> or renamed the connection remains, but pickled string data containing object >> names will become invalid. ( on a side note: houdini creates a unique id >> for every node in every file for all time. that's pretty handy. i wish >> that maya would do that natively, though there are ways of hacking it into >> place.) >> >> -chad >> >> >> >> On Jan 12, 2010, at 9:10 PM, JP wrote: >> >> > Hi all, >> > >> > I'm currently working on a script that allows for space-switching >> > between objects, and came across some general questions regarding data >> > persistence. >> > >> > In short, I have a couple classes I've created that represent parents, >> > children, etc, and was thinking about how to keep track of some of >> > this data. In the past, I've used the tried-and-true method of >> > connecting .message attributes between objects and then checking for >> > them later. While this works, it's not terribly elegant, and when I >> > start having a lot >> > of data I want to keep track of, it becomes cumbersome to inspect all >> > of those connections. >> > >> > I was wondering if anyone had experimented with creating file-like >> > objects from script nodes (or other nodes) that would allow something >> > like this: >> > >> > f = ScriptNodeFile("spaceSwitching", "r") >> > f.write("Some line of text \n.") >> > f.close() >> > >> > It would also be very very cool if you could pickle data to this >> > ScriptNodeFile object! >> > >> > Obviously, pickling/saving an external file with this data would work, >> > but I'm almost certain these would be quickly lost in our file >> > system. I think it would be very handy indeed to be able to store and >> > recall data to a node within the scene file. Just wondered if anyone >> > out there had come across anything like this, or had any bright ideas >> > that might help me with this sort of thing. >> > >> > Thanks! >> > -- >> > http://groups.google.com/group/python_inside_maya >> >> >> -- >> >> http://groups.google.com/group/python_inside_maya >> > > > > -- > John Patrick > 404-242-2675 > [email protected] > http://www.canyourigit.com > > -- > http://groups.google.com/group/python_inside_maya >
-- http://groups.google.com/group/python_inside_maya
