Mark project dirty via python

Hi there,

I am sorry, if that has been answered before. Can I mark a project dirty via python?
I am changing contents of a dat via python and I would like TD to ask the user to save on close.

Cheers, David

No price for beauty, but the easiest hack would be to use a DAT Execute on that table, and make it change something random in your project when the onTableChange callback fires, for instance write the current datetime to a Text DAT or something.

For a better user experience I started writing something for you which invokes a nice messagebox with a warning and a save button on quit, but - ahum- as soon as you write to any variable or extension property to enable that messagebox on exit, TD of course marks the project immediately dirty and invokes his own save dialog first on quit :laughing:
That was not too sharp of me - but here’s that save on quit function anyway, maybe it’s still useful to you - quit the project without changing anything to see it - if you do change anything you’ll see TD’s dialog first.
savewarning_on_quit.toe (4.06 KB)

Thanks nettoyeur, thats what I figured.

related to this, how do you read the “dirty” state of a project with Python? Along with a need to “dirty” a project when moving GUI objects that don’t always trigger it, I wanted to build a “dirty” indicator similar to the * on title bar for a fullscreen-mode GUI.

What version are you guys in? There are some new (and undocumented) features that will help you. Check out dir(ui.undo) if you’re in 30k branch.

Years later and I find myself in the same situation :persevere:
Did anyone find a solution to this?
I can’t find something with dir(ui.undo), that would help with this.

And 2 years later and I am again in the same situation.

I change the storage of a Comp via python, but since this doesn’t mark the project dirty I don’t get prompted to save on close.

Same issue as here:

Building something with an onExit execute doesn’t work, as mentioned here:

Writing something to a textDAT via python doesn’t do the trick either.

Is there anything I’m overlooking or could we get the possibility to mark a project dirty?

Best regards,
David

One thing I’ve experimented with is hashing the byte array of a tox - this works pretty well, but does take some work to make sure it’s targeted at the right granularity for your saving process / procedure. I wouldn’t say that it’s easy out of the box, but it is a way to capture if something needs to be saved.

The process looks something like:

  • generate a list of all external ops
  • generate an initial hash of each initial op
  • use a hot key to show a save menu - loop through and rehash your external ops, and then mark the appropriate ops as dirty.

I think this would capture a change in storage so you can see which ops need to be saved.

As a note this approach is pretty expensive - computationally speaking - so it’s not something you want to leave on in your project. In my experience it’s something I’ve wanted to run on demand, and not automate - since it can cause unexpected frame drops.

thanks matthew, I will give this a try, although I really would like a dirty attribute on the project object, that we could set to True to trigger a save dialog on close.

Best wishes,
David