0

I have an addon with several operators. There is one operator that needs to be pressed first before other operators are displayed. This is the general idea of what I have:

context.types.Scene.my_bool = bpy.props.BoolProperty(
     default = False
)

class FirstButtonOperator(bpy.types.Operator): def execute(self, context): context.scene.my_bool = True #do other random stuff here

class SecondButtonOperator(bpy.types.Operator): def execute(self, context): #do random stuff here

class MyPanel(bpy.types.Panel): def draw(self, context): layout = self.layout if not context.scene.my_Bool: #draw first operator else: #draw second operator

Every time blender is opened, I want the second button to be displayed only after the first button is pressed. The code works the first time I run it. However, when I save the blender file, my_bool is saved as True. Hence, the next time I open blender, the second operator displays instead of the first one.

Is there a way I can reset my_bool to False every time blender is opened? If not, are there other ways I can accomplish my goal? I'm new to blender, so I'm not sure if I'm doing things in the optimal way.

Alex
  • 1
  • 1
  • Rather than reset the prop at start, you could reset it at exit : https://blender.stackexchange.com/a/48566/86891 – Gorgious Jul 15 '21 at 10:54
  • Multiple ways to do that (depending on your logic). The easiest is to add 'SKIP_SAVE' option to your property: https://blender.stackexchange.com/q/94035/31447 or calling property_unset(): https://blender.stackexchange.com/a/72852/31447 Also, I recommend take the tour to learn about how this site works: https://blender.stackexchange.com/tour – brockmann Jul 15 '21 at 10:59

0 Answers0