Trigger Autosave
-
Hi!
Super new to coding in Python and with C4D. I'm making a script, and I was wondering if there is a way to add a few lines so that when you execute a script, it also triggers an Autosave. That is, the current file will get saved to its Autosave location with the date and time appended, but your current document will stay the same.Thank you!
-
Hello @honear,
welcome to the forum and welcome to the Cinema 4D coding community. Please excuse the slight delay in answering you, but we are currently in the midst release preparations. Please make sure to read the forum guidelines, especially regarding Forum Structure and Features: Tagging to add the necessary information to your postings, namely the coding environment, the OS and the used version of Cinema 4D.
I have added the Python tag for you, you will need to fill in the rest of the information.
Regarding your question: It depends a bit on how it is meant. In general, the autosave functionality cannot be invoked through our APIs. But you can save a document through
c4d.documents.SaveDocument()
. The location of a document is attached to a document viaBaseDocument.GetDocumentPath()
and.GetDocumentName()
. Which would allow you to save the document with any pre- and post-fixes of your liking.You can also access the autosave settings in the user preferences via the settings container of a Cinema 4D instance as returned by
c4d.GetWorldContainer()
. With that information you could mimic the Autosave functionality completely. This later step might be a bit overwhelming, depending on your general level of comfort with APIs and coding.We cannot write code for you, so I would suggest that you start out with writing a small script that saves a document to the same path with some pre- and post-fixes, and we will then help you with the rest. Please make sure to post your code or examples of your code for further steps then.
Cheers,
Ferdinand -
Hi Ferdinand,
No worries! Thanks for the reply, it was very helpful as a starting point. I ended up using the
c4d.GetWorldContainerInstance()
and thenc4d.WPREF_AUTOSAVE_DEST_PATH
to get the custom filepath and then just a SaveDocument with the AUTOSAVE flag seems to be doing the trick. thanks again!