Isotropix Forums

Attribute list enabling/disabling not working?

Clarisse Scripting related topics

Attribute list enabling/disabling not working?

Unread postby briansilva » Wed Feb 19, 2020 4:46 pm

Hello! I have a file list attribute I'm trying to drive in Python, but the API for managing the enabled/disabled state doesn't seem to be working.

For example, I create a box and add a custom attribute to it:

python code

item = ix.get_item("project://scene/box")
attr_layers = item.add_attribute(
"layers",
ix.api.OfAttr.TYPE_FILE,
ix.api.OfAttr.CONTAINER_LIST,
ix.api.OfAttr.VISUAL_HINT_FILENAME_OPEN,
"CUSTOM",
)


then add some values to it.

python code

ix.cmds.AddValues(["project://scene/box.layers"], ["c:/layer1"])
ix.cmds.AddValues(["project://scene/box.layers"], ["c:/layer2"])
ix.cmds.AddValues(["project://scene/box.layers"], ["c:/layer3"])


From then on, I can enable/disable the list items through the UI, but nothing in the Python API seems to work:

python code

ix.cmds.DisableAttributeValue(["project://scene/box.layers"], [1], False)  # does nothing

print item.get_attribute("layers").is_value_disabled(1) # always False (even after disabling through UI)
print item.get_attribute("layers").is_any_value_disabled() # always False
layers = ix.api.CoreStringArray()
item.get_attribute("layers").get_values(layers, ix.api.OfAttr.VALUE_PAGE_CURRENT, False) # always returns all items, despite setting consider_disabled to false
print list(layers)


Is this broken, or am I missing/misunderstanding something?

Thank you!
briansilva
 
Posts: 53
Joined: Mon Mar 25, 2019 12:43 pm

Re: Attribute list enabling/disabling not working?

Unread postby anemoff » Thu Feb 20, 2020 1:52 pm

This is a limitation of attributes of container type CONTAINER_LIST.
Currently, only types TYPE_OBJECT, TYPE_REFERENCE, and TYPE_STRING support enabling/disabling individual values in the list. For other types, changing the disabled status does nothing.

In your case, you can simply change TYPE_FILE to TYPE_STRING. Be sure to use one of the FILENAME visual hints otherwise the UI doesn't show the "eye" column to toggle the status (this is another limitation)

Cheers,
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 300
Joined: Wed Jan 13, 2016 10:10 am

Re: Attribute list enabling/disabling not working?

Unread postby briansilva » Thu Feb 20, 2020 3:40 pm

Ah perfect, thank you! It works great now.
briansilva
 
Posts: 53
Joined: Mon Mar 25, 2019 12:43 pm


Return to Scripting
cron