import pymel.core as pm
pm.optionVar["test"] = []
print pm.optionVar["test"]
# Error: test
# Traceback (most recent call last):
# File "<maya console>", line 3, in <module>
# File "E:\Autodesk\Maya2016\Python\lib\site-packages\pymel\core\language.py", line 531, in __getitem__
# raise KeyError, key
# KeyError: 'test' #
I usually create my option variables in the init of my modules - but for some reason this will not execute:
if “test” not in pm.env.optionVars: pm.optionVar[“test”] = []
…which is odd because the row after it tries runs the same code, but with the key “test2”. So I tried to create it using the above code and then print the result to make sure it’s “there” - and then I get this weird KeyError saying it doesn’t exist!?!
Is there a cap or something on how many optionVars you can create?