I found the problem this is not the issue.
Posts made by potashalum
-
RE: Dialog generates EVMSG_CHANGE messages
-
RE: Dialog generates EVMSG_CHANGE messages
@m_adam said in Dialog generates EVMSG_CHANGE messages:
So the second script works because you moved the dialog definition outside of the main function, so the dialog variable is now a global variable. But in any case, it's not really a good thing, since at each execution, the scope is renewed (meaning all global variable trashed, so you will create a memory leak).
The second script is the one that does NOT work, meaning that it produces EVMSG_CHANGE messages. I took this code out of a much larger piece of code that is run from the plugins folder when cinema starts not the script manager it also does not use global variables, this was only meant for the demonstration of the problem with the minimum amount of code. In the actual use case the dialog is being created by a command data plugin and saved as a member variable. The problem still persists.
The command data plugin that creates the dialog:
class CollectionManagerCommand(c4d.plugins.CommandData): dialog = CollectionManager() def Execute(self, doc): return self.dialog.Open(c4d.DLG_TYPE_ASYNC, res.COLLECTION_MANAGER_PLUGIN_ID) def RestoreLayout(self, secret): return self.dialog.Restore(res.COLLECTION_MANAGER_PLUGIN_ID, secret) def register(self): return c4d.plugins.RegisterCommandPlugin(res.COLLECTION_MANAGER_PLUGIN_ID, res.string('IDS_COLLECTIONMANAGER'), c4d.PLUGINFLAG_HIDEPLUGINMENU, res.bitmap('res/icons/manager.png'), "", self)
-
Dialog generates EVMSG_CHANGE messages
Hi,
I am running into this problem that when create a dialog and keep its reference alive it generates an EVMSG_CHANGE message whenever I click in the viewport.
I am using Cinema 4D R21.115 on windows.
Here is a small test I created that does not generate any EVMSG_CHANGE messages.
import c4d class CollectionManager(c4d.gui.GeDialog): def CoreMessage(self, kind, data): if kind == c4d.EVMSG_CHANGE: print("Something changed") return super(CollectionManager, self).CoreMessage(kind, data) # Main function def main(): dialog = CollectionManager() dialog.Open(c4d.DLG_TYPE_ASYNC, 1040130) # Execute main() if __name__=='__main__': main()
Here is the same code with the only difference being that the variable dialog has been moved out of the function and into the global scope. This generates EVMSG_CHANGE messages whenever I click in the viewport/editor window.
import c4d class CollectionManager(c4d.gui.GeDialog): def CoreMessage(self, kind, data): if kind == c4d.EVMSG_CHANGE: print("Something changed") return super(CollectionManager, self).CoreMessage(kind, data) # Main function dialog = CollectionManager() def main(): dialog.Open(c4d.DLG_TYPE_ASYNC, 1040130) # Execute main() if __name__=='__main__': main()
It might be something that don't quite understand but any help would be greatly appreciated.
Best Regards,
Alamgir Nasir -
RE: PreferenceData plugin, Text disappears when directory is set
Hi @m_adam,
No problem, I hope you had great holidays and thank you for confirming the problem.
Regards,
Alamgir -
RE: PreferenceData plugin, Text disappears when directory is set
Hi @m_adam,
I updated the GetPreferenceContainer function as well, it did help in that the SetDParameter function works now, which didn't before. So that is definitely better. But the GetDParameter function didn't work, even if I only use your code.
Could it be a problem in the res files? Would you mind taking a look please. I tried my best to get those right but maybe I still have an error there.
Regards,
Alamgir -
RE: PreferenceData plugin, Text disappears when directory is set
Thank you for your help @m_adam, but I am still having the same problem.
Using
GetCustomDataType
doesn't give me any errors but it doesn't work either. It still clears the string immediately after I set the field.It does seem like the problem is still with the
GetDParameter
, because if I comment it out everything works except that the filename isn't loaded when cinema is restarted. -
PreferenceData plugin, Text disappears when directory is set
Hello everyone,
I am having this problem that when I try to use a Filename parameter to get the path of a directory,
It either, in case I don't override the GetDParameter and SetDParameter functions does not save the path,
or, in case I do override these functions and set and get the plugin container myself, the path text in the UI disappears.If someone can have a look I will greatly appreciate it. I created a self contained project illustrating the problem. Just unzip it in the plugins folder and it should work.
I am also going to go ahead and paste the python code here, in case some one can find something just by looking at the code, there is also of course accompanying resource files that are included in the zip file.
Thank you,
Alamgir Nasirimport c4d PREFERENCE_PLUGIN_ID = 1040402 PREFERENCE_RENDER_PATH = 1000 def GetPreferenceContainer(): world = c4d.GetWorldContainerInstance() if world is None: return None bc = world.GetContainerInstance(PREFERENCE_PLUGIN_ID) if bc is None: world.SetContainer(PREFERENCE_PLUGIN_ID, c4d.BaseContainer()) bc = world.GetContainerInstance(PREFERENCE_PLUGIN_ID) if bc is None: return None return bc class TestPreference(c4d.plugins.PreferenceData): def GetDParameter(self, node, id, flags): bc = GetPreferenceContainer() if bc is None: return False # Retrieves either check or number preference value paramID = id[0].id if paramID == PREFERENCE_RENDER_PATH: return (True, bc.GetFilename(PREFERENCE_RENDER_PATH), flags | c4d.DESCFLAGS_GET_PARAM_GET) return False def SetDParameter(self, node, id, data, flags): bc = GetPreferenceContainer() if bc is None: logger.error("SetDParameter: bc is none.") return False # Changes either check or number preference value paramID = id[0].id if paramID == PREFERENCE_RENDER_PATH: bc.SetFilename(PREFERENCE_RENDER_PATH, data) return (True, flags | c4d.DESCFLAGS_SET_PARAM_SET) return False def Register(self): print("Registered test preferences") return c4d.plugins.RegisterPreferencePlugin( id=PREFERENCE_PLUGIN_ID, g=TestPreference, name="TEST", description="testpreference", parentid=0, sortid=0) TestPreference().Register()