# Custom Property vs ID Property for temporary User Preference Variable?

I was making a modal operator and I needed some kind of global variable I could use as a "user preference" if you will. Whenever the operator is run, it checks if the value is True or False and runs the necessary code. If it doesn't exist then it creates it with a default value.

I managed by using something like this (an ID property?) which is great because I think it's saved with the scene and not per object:

context.scene["My Property"] = False


My code is already working just fine, no problems there. However, I discovered I can also do this (with optional extras I imagine are useful/necessary for UI Panels):

my_property : BoolProperty(default=False, name..., min... max...)


I just use this property to remember to turn on the wireframe for a selected object while the operator is running, that's it. I don't need to display it in any menu (at least not at the moment) and I don't need to save it in any file; it's just a temporary, non-persistant user preference.

My Question:

# Is there's any benefit of one method over the other if I just use it like a global variable?

I've read about Custom vs ID Properties but I'm too much of a layman to understand when to use different things.

• The first won't work if the current scene is deleted. You'd usually want a collection of properties for your add-on. – Robert Gützkow May 14 at 20:04
• Yes of course but its just a temporary user preference I want to save for that particular session. It just remembers to turn on the wireframe for the selected object while the operator is running (if the var is True). – Armored Wolf May 15 at 4:00

## 1 Answer

I decided to do this because it just works:

my_property : BoolProperty(default=False)
...
if button_pres_event: # Not real code
self.my_property = not self.my_property
do some stuff


I prefer this over the Scene ID Property I had before because it automatically creates it when the operator runs (no more checking if it exists first) and I can easily give it a starting value.

Basically, it simplifies the code. I'm sure there are other benefits but simpler/easier code is a good enough excuse for me.