Hello! So, I couldn’t google my way out of this one.
I’m (finally) re-writing a script from last year. It served me (surprisingly) well, but there are a bunch of additional functions I’d like to add.
Now, the new script adds objects of four different “types”. These types would define which values from Modifiers/Constraints/whatever will be exposed in a panel and how a certain function will affect the object. The question is: how do I define a property like this?
Simply create a String Property: objectType = “TYPE_2”?
Or can I make it accept ONLY these four values? Some sort of list or something: (TYPE_0; TYPE_1; etc)?
Where/how should I define this property?
I know only enough programming (C++ mostly, though) to brute-force a script into running, so I’d appreciate simple words
Thanks!
Hi StrayBillie,
sounds like you are looking for an enumproperty. If you know cpp, you will likely know what an enum is. But nonetheless there’s an example here:
In principle an enum is just an enumeration. Its a association between a constant number and a value, eg a traffic light might be described like this:
1 is green
2 is yellow
3 is red
Yes, it will. The principle itself has very little to to with it being an enum, so to understand it easier I chose a BoolProperty here instead and started it on the default scene.
I hope that makes it clearer how its defined and used.
There are IDProperties. These are defined/added individually per object, but its typewise much more restricted and there is no such thing as an enumproperty there. But yeah its an alternative.