tredeger
10-13-2006, 08:02 AM
Hi again everybody. You sick of me yet? Well, thanks to all of you for your patience and generosity.
I've encountered some very odd behavior. I have an array attribute whose default initial value for new elements is -1. So when I first do a getAttr on the whole attribute, I get a result like:
// Result: -1 -1 -1 -1 -1 -1 //
I then try to set all the attrs in a for loop, one at a time. I do this based on another array with the following values {4, 3, 5, 1, 2, 0 }
But I get:
// Result: 0 3 5 1 2 0 //
If I run the exact same procedure a second time, I get a correct result:
// Result: 4 3 5 1 2 0 //
The only thing different is that the values have already been set once. But why wouldn't the first element of the attr set correctly the first time, and why would it decide to set itself to 0, which is neither the initial default value nor the correct value?
Unfortunately, this screwed up value ends up causing problems in some functions in my plugin which rely on correct values. The error ends up compounding into a wild garbage value in a calculation, sufficient to cause a fatal error. Grrrrrr.
If any of you know what pecularities are causing this and if there is a resonable and elegant work around, please let me know. Thanks and cheers!
I've encountered some very odd behavior. I have an array attribute whose default initial value for new elements is -1. So when I first do a getAttr on the whole attribute, I get a result like:
// Result: -1 -1 -1 -1 -1 -1 //
I then try to set all the attrs in a for loop, one at a time. I do this based on another array with the following values {4, 3, 5, 1, 2, 0 }
But I get:
// Result: 0 3 5 1 2 0 //
If I run the exact same procedure a second time, I get a correct result:
// Result: 4 3 5 1 2 0 //
The only thing different is that the values have already been set once. But why wouldn't the first element of the attr set correctly the first time, and why would it decide to set itself to 0, which is neither the initial default value nor the correct value?
Unfortunately, this screwed up value ends up causing problems in some functions in my plugin which rely on correct values. The error ends up compounding into a wild garbage value in a calculation, sufficient to cause a fatal error. Grrrrrr.
If any of you know what pecularities are causing this and if there is a resonable and elegant work around, please let me know. Thanks and cheers!
