0
$\begingroup$

I create some lists using EnumProperty. The lists may be empty, because nothing in the lists. Therefore, I get some warning in the console. "RNA Warning: Current value "0" matches no enum in......." How to get rid of the warning in the console? I don't want to add some "NONE" in the lists when the lists are empty.

$\endgroup$
4
  • 1
    $\begingroup$ AFAIK enum props are expected to have at least one element. Are they dynamic enums? what is the issue with having a dummy 'NONE' enum when empty? $\endgroup$
    – batFINGER
    May 25 '18 at 16:23
  • $\begingroup$ Yes, they are dynamic enums. I am using an add-on makehuman. They also have the enums, but they don't show rna warning when the enums are empty. I don't know why my code have rna warning. @batFINGER $\endgroup$ May 25 '18 at 16:59
  • 1
    $\begingroup$ Do you have any UI code accessing the empty enums? $\endgroup$
    – batFINGER
    May 25 '18 at 17:07
  • $\begingroup$ Yes. I create some buttons to import the object on the list. @batFINGER $\endgroup$ May 25 '18 at 19:10
1
$\begingroup$

You can avoid this problem by adding a dummy to the list e.g. 'NONE' which will be used if there is nothing else to draw. This way you can also detect if the list is actually drawn/used for the UI:

("NONE", "None", "", 1),
("RED", "Red", "", 2),
("GREEN", "Green", "", 3),
("BLUE", "Blue", "", 4)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.