Today a weird thing happened in our pipeline concerning an expression and global variables.

We're doing a car movie and we used a script that rotates the wheels automatically based on the car's positions, it stores an 'old position', gets the current frame position and does the math to rotate the wheels. I don't know why, but the expression was designed to store these vectors in global variables... by simply creating attributes in the car's reference to store this data, we could point each expression to its own attributes and conflicts wouldn't happen, but I didn't write the script and it's not the case.

I was called because the wheels weren't moving in a scene with more than 1 car.
I thought that it would take too much time to retarget the global variables to local attributes so I started doing some tests to see when the expression broke.
First I referenced two cars together. Even with the global variables being set in the wheels expression, both cars were working perfectly! Weird isn't, it? It's like there was some kind of 'namespace' in variables. Then I thought it could be a Maya save/load thing that broke it all and did that. Saved and loaded a test scene. Nothing happened, the car rig was still working.

Imported the references and the wheels still worked. Asking some people, I discovered that in order to gain more flexibility and avoid multiple reference levels, the render team imported the cars directly into the scene and that led to the errors and the wheels not moving. Whilst if we referenced the car before importing, the expressions did not get messed up.

Comparing the expressions from directly-imported and referenced-imported cars, they're identical, except from the obvious namespaces that Maya creates in the expression names:
CAR1_expression1_l_front_tire (direct imported name)
CAR1:expression1_l_front_tire (referenced imported name)

I'm guessing it does create some kind of namespace into variables, even though I can't access them thru mel:
print $l_front_wheel_old_pos
...prints me the last wheel evaluated. And there is NO way I can access something like CAR1:$l_front_wheel_old_pos.

Later on this week, I'll be notified if the reference-before-import works to keep the expressions up and running. Or not. >_>

Any ideas on this matter?

:)