Invoke Dialog from Python Tag
-
Hi,
I do have some Python Tags and need to display a dialog to get a yes/no user decision in certain cases.
I actually did this for a long time on macos, but know now why this leads to freezes on Windows.My first idea for a solution was to message from the python tags to a commanddata plugin, which then would display a dialog and take action.
Is that possible and how can I do that?
CallCommand() is not allowed from a python tag and something like this doesn't seem to work either:op = c4d.plugins.FindPlugin(PLUGIN_ID) bc = c4d.BaseContainer() ... op.Message(c4d.MSG_BASECONTAINER, bc)
best, index
-
hi,
you can have a look at this thread there are some important point there.
While it's true you can't use CallCommand inside the
Execute
function of the tag, you can in themessage
function.
You have to use them in the main thread and if you are now sure, you can use GeIsMainThreadAnother important point is, do you want to open a modal or async dialog ?
Let me know if you still have issue.
Cheers,
Manuel -
Thanks Manuel,
I saw this thread before, and I must study it more in depth, but one thing ...
I don't use a Tag Plugin, I use a Python Tag.
So the Plugin with the Gedialog is not connected to the Tag.I want to send a Message from a Python Tag to a Commanddata Plugin
The Gedialog there can be Async or Modal, that doesn't matter.Btw, another way to solve my problem would be to catch MSG_DOCUMENTINFO_TYPE_LOAD
from a Commanddate Plugin and check all Python Tags in the Scene from there.
But I read this is not possible using Python... (?)best, Index
-
# IN A MESSAGEDATA PLUGIN def CoreMessage(self, id, msg): if id == PLUGIN_ID: print "Hello World!" return True # IN A PYTHON TAG (NOT TAG PLUGIN) c4d.SpecialEventAdd(PLUGIN_ID)
hm, this seems to work using a MessageData plugin,
but isnt it possible to receive a (Core)Message in a CommandData plugin? -
hi
a CommandData can't react to CoreMessage
Only GeDialog, MessageData and GeUserArea, and SDKBrowserPreviewDialog can react to a CoreMessage.
The message,
MSG_DOCUMENTINFO_TYPE_LOAD
is broadcast to all NodeData. (including SceneHookData but not PreferenceData). It's not a CoreMessage.So to resume, you want your tag to display a dialog and that dialog will call a command with some parameter ?
Cheers,
Manuel -
Hi Manuel,
I just thought it must be possible to Message something to a CommandData plugin, too.
The idea behind the CommandData was to combine some other functionality,
but I guess i just get a new plugin ID and go the MessageData way...best, Index
hm, somehow I cant find how to tag this as solved