I have a script that modifies attributes on different nodes based on some criteria.
But the script dies if the attribute cannot be modified because another attribute has disabled the attribute in question.
Here is a sample of the script (this is just one portion, it does more than just unlock attributes):
- Code: Select all
# Check the locked status of the attribute and unlock if needed
locked = False
if attr.is_locked():
locked = True
ix.cmds.LockAttributes([item.get_full_name() + "." + attr.get_name()], False)
value_count = attr.get_value_count()
for i in range(value_count):
if expressions[i] != "":
ix.cmds.SetExpression([item.get_full_name() + "." + attr.get_name() + "[" + str(i) + "]"], [new_expression])
But when it runs it can easily fail if the attribute in question is not enabled because another attribute is set to 0. In this case, I get this error:
- Code: Select all
Attribute 'project://asset_veg_bamboo_ac/shading/leaf/support/material_leaf.transmission_color' cannot be unlocked.
Attribute 'project://asset_veg_bamboo_ac/shading/leaf/support/material_leaf.transmission_color[0]' is not editable.
In the example above I have a MaterialPhysicalStandard and I want to modify the Transmission Color. Unfortunately this script fails if the Transmission Strength is set to 0.
I could do a test for the Transmission Strength and see if it is 0, but that poses a number of problems:
1) The Transmission Strength is being driven by an expression, so I cannot easily set it to something other than 0 temporarily just to modify the values in the transmission color.
2) This script needs to be generic, and I don't really want to code exceptions for every attribute on every node type that might be disabled because some other attribute is set to 0.
Is there a better way to modify attributes that might be disabled?
Thanks
(We are still on sp5b because the later service packs process scatters differently and our scatters do not line up with previous renders from last year. If this is something that is not an issue in newer service packs, I can make sure we only run this script when in a newer version of Clarisse).