Skip to content

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

@mischakolbe

Description

@mischakolbe

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.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions