ELF elements -- efficiency of relative paths

Hello!

Simple question that occured to me: I tend to use relative paths when querying/editing a ui element (i.e. just the simple name of the element), unless an absolute path is necessary. I'm wondering if anyone can comment on the efficiency of this, or lack of. Am I wasting cpu searching through some widget hierarchy?

It's just so much either to deal with relative paths. I'd hate to have to start naming all my layouts, or retain their auto-generated names in global variables....

Thanks for any insight,

  • Matthew Durante

This is the general rule I use for all of my UI elements...

If I need the name of the control later in a proc then I name the control, otherwise I let Maya generate a name for it. I'd avoid global varibles at all cost!

example...
proc sampleUI()
{
string $window = window;
columnLayout;
radioButtonGrp -numberOfRadioButtons 3
-label "Three Buttons"
-labelArray3 "One" "Two" "Three"
sw_number;
button -c "doStuff";
showWindow $window;
}

global proc doStuff()
{
int $number=radioButtonGrp -q -sl sw\_number;
print $number;
}

--g

I see, thanks.

But is it more efficient to do:
int $number=radioButtonGrp -q -sl WhateverWindow1|columnLayout1|radioButtonGrp1|sw\_number;
- or whatever the full path would be?

Okay so I'm probably being nit-picky. But what if you have a scrollLayout with 100's of children?

  • Matthew Durante

I have no idea, but my guesse would be no. The reason I say that is because of the way nodes work in Maya. Is it fast to say "select obj1" rather than "select |someNode|anotherNode|obj1" ? I don't think it is.
The only time you would need to do this is if you have 2 children called obj1 and I would think the same applies to ELF elements.
On the other hand I could be completly wrong;)

--g

Maeasure the time. But why does it matter?

Anyway i can find many reasons why a relative path is faster than a absolute one. If you compare this with how a file structure works. BUt overall id say thet theres no way one can know for certain as it varied depending on many things! So it might sometimes be and sometimes not. And the outocme isnt allways the same.

Thanks guys for commenting.

If I ever do any speed comparisons I'll post back for anyone interested. Always try to find the best way!

  • Matthew Durante

But i dont think you can say definetly.. because it waries based on starting point.