Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
I basically want to react in my GeDialog if my active document has been closed. I'm currently looking at MSG_DOCUMENTINFO but there's no flag for a closed document... one other idea would be to listen to a CallCommand for example via c4d.MSG_DESCRIPTION_COMMAND?
GeDialog
MSG_DOCUMENTINFO
CallCommand
c4d.MSG_DESCRIPTION_COMMAND
What would be the best way to approach this..?
Thanks, Lasse
Hi Lasse,
MSG_DOCUMENTINFO provides MSG_DOCUMENTINFO_TYPE_REMOVE and MSG_DOCUMENTINFO_TYPE_SETACTIVE.
MSG_DOCUMENTINFO_TYPE_REMOVE
MSG_DOCUMENTINFO_TYPE_SETACTIVE
Yo you could do a simple compare when a new active doc is set, if your desired document still exists.
Hi @lasselauch,
thank you for reaching out to us. @mp5gosu provided to some degree the correct answer (thanks for that). However, you should consider that not all message types are being sent to all Message methods. In the c4dpythonic way of looking at Cinema's public API, MSG_DOCUMENTINFO is part of the MSG PLUGINS channel which is only being broadcasted to plugin nodes. So you won't be able to receive it in a dialog's Message or CoreMessage method.
Message
CoreMessage
The easiest way would be to use some kind of plugin node for that. I currently do not see a way to do this in a GeDialog, but I might be wrong. We will discuss that tomorrow in the SDK Team, to see if the others know a clever way to do that. Just wanted to make sure that you do not run down a rabbit hole with no exit
Cheers, Ferdinand
Thanks, @mp5gosu ...!
@zipit said in Detect closing of Document:
Hehe, yeah that's exactly what I thought when looking at MSG_DOCUMENTINFO . Thanks for the quick answer, Ferdinand. Looking forward to your thoughts and ideas...
Cheers, Lasse
I guess I found a workaround... I cannot show the whole code involved but something along those lines:
I have a Treeview that stores an absolute path abs_path of different documents... Now, I just check if one of these filepaths is in my open documents paths via: get_all_docs_paths()
Treeview
abs_path
get_all_docs_paths()
def get_all_docs_paths(): all_docs_paths = [] first = c4d.documents.GetFirstDocument() while first: folder = first.GetDocumentPath() abs_path = os.path.join(folder, first.GetDocumentName()) all_docs_paths.append(abs_path) first = first.GetNext() return all_docs_paths
If yes, the document is open, if not it is closed.
By the way, I also ended up multiple times implementing a message plugin for those kind of actions. MessageData plugins are extremely simple to implement and expand your flexibility a lot!
we talked about your problem this morning. There are two ways of looking at your question:
CommandData
MessageData
TagData
GeDialog.Timer