node_calculator icon indicating copy to clipboard operation
node_calculator copied to clipboard

Concatenation of attrs is different on NcAttrs isn't always desired.

Open mischakolbe opened this issue 4 years ago • 0 comments

a is an NcNode, without any attrs. b is an NcAttrs, with the attribute tx. b.ty is concatenated onto b.tx and gives b.tx.ty rather than replacing it with b.ty. This looks like a design flaw but is actually crucial for supporting nested attributes, such as plusMinusAverage.input[0].inputX. If the inputX wouldn't be added to the rest, it would have no meaning: plusMinusAverage.inputX. The problem is that I (think I) can't distinguish between these cases. In both an NcAttrs instance gets 2 getattr instructions. In one we want the concatenation and in the other we don't.

a = noca.locator("test")
b = a.tx
b.ty = 2
# Error: RuntimeError: file E:/Dropbox/__SoftwareSpecific__/Maya/scripts/node_calculator\node_calculator\om_util.py line 642: mplug test5.tx.ty doesn't seem to exist! # 

In most cases this works ok, because we get NcNode instances back when using Operators and such. There it starts "fresh" the first time. Even though we initialize the locator with the attribute tx - it's an NcNode instance. Then, when accessing ty we get an NcAttrs instance back, which ignores the NcNode attribute.

a = noca.locator("test", attrs="tx")
a.ty = 2
# Works fine

Current conclusion: I can't think of a better solution.

mischakolbe avatar Aug 02 '20 18:08 mischakolbe