SAVEDOCUMENTFLAGS_AUTOSAVE still added to the recent file list?
-
hi there,
i recreated the autosave functionality (and tweeked the post-fix a bit) to be able to trigger it on demand.
then i noticed the saved files still show up in the recent file list, even though i added the SAVEDOCUMENTFLAGS_AUTOSAVE flag. the documentation says this should not happen. adding SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST makes it work.
is this correct or a bug or something else wrong with my code?cheers sebastian
import c4d, os, datetime doc: c4d.documents.BaseDocument # The currently active document. op: c4d.BaseObject | None # The primary selected object in `doc`. Can be `None`. def main() -> None: # autosave doc_path = doc.GetDocumentPath() doc_name = doc.GetDocumentName() now = datetime.datetime.now().strftime("%Y%d%m_%H%M%S") doc_name_post_fix = f"{doc_name}@export_{now}" prefs = c4d.GetWorldContainerInstance() ausosave_on = prefs[c4d.WPREF_AUTOSAVE_ENABLE] ausosave_dest = prefs[c4d.WPREF_AUTOSAVE_DEST] # 0=project, 1=custom, 2=user if ausosave_on: if ausosave_dest==0: if not doc_path: #print( "no doc path, fallback to user" ) doc_path = c4d.storage.GeGetStartupWritePath() save_path = os.path.join( doc_path, "backup", doc_name_post_fix ) if ausosave_dest==1: doc_path = prefs[c4d.WPREF_AUTOSAVE_DEST_PATH] if not os.path.isdir(doc_path): #print( "no custom path, fallback to user" ) doc_path = c4d.storage.GeGetStartupWritePath() doc_path = os.path.join( doc_path, "backup") save_path = os.path.join( doc_path, doc_name_post_fix ) if ausosave_dest==2: doc_path = c4d.storage.GeGetStartupWritePath() save_path = os.path.join( doc_path, "backup", doc_name_post_fix ) #print( save_path ) res = c4d.documents.SaveDocument(doc, save_path, saveflags=c4d.SAVEDOCUMENTFLAGS_AUTOSAVE | c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, format=c4d.FORMAT_C4DEXPORT) if not res: print( "error writing autosave on export" ) if __name__ == '__main__': main()
-
Hey @datamilch,
Thank you for reaching out to us and pointing this out. Your request has almost everything what makes a good request, executable code, and a contrast of what you think something should be and what is not working. But please provide instructions on how to use your code when required in the future. E.g., here 'expects a Cinema 4D instance with auto save enabled and a
backup
folder next to the saved current document'. I can of course read code to figure out why something is not working, but the more complex a code snippet gets, the greater the chance will be that we label something simply as "not executable" and not bother with finding out why a code example does not run on the first try.About your question: I had a brief look at our code base, and the auto save itself uses this instruction:
and the save handler then only checks for
SAVEDOCUMENTFLAGS::DONTADDTORECENTLIST
to determine if it should put a saved document into the recent list or not. So, I would say it is fairly safe to assume that our documentation simply degraded there a bit. I have removed the bit onSAVEDOCUMENTFLAGS_AUTOSAVE
which talks about the recent file list.So, TLDR, your script is the correct way to do it.
Cheers,
Ferdinand -
@ferdinand said in SAVEDOCUMENTFLAGS_AUTOSAVE still added to the recent file list?:
But please provide instructions on how to use your code when required in the future.
oh shit, i'm so sorry. you're right. completly missed this one.
...
and of cause thanks for the explaination / clarification.