id PluginMessage () when the scene loaded



  • Hello!
    I need to find the Message ID when the scene has already loaded, so that after that I can run the plugin that will work with objects on the scene, it is important to make this plugin automatic, that is, without clicking on the button in the plugin gui. As it should be: Cinema4d started > Scene loaded > plugin started > plugin get objects > plugin work with objects. Please help, Google does not help



  • I don't think this will work for a Python plugin, but with C++ you can provide a SceneHook and use message MSG_DOCUMENTINFO_TYPE_LOAD



  • @C4DS, Hi!
    it is very sad. I don't really want to rewrite the plugin from Python to C++ 😢



  • @C4DS said in id PluginMessage () when the scene loaded:

    I don't think this will work for a Python plugin, but with C++ you can provide a SceneHook and use message MSG_DOCUMENTINFO_TYPE_LOAD

    Maybe there is another way to start the plugin automatically? Mb is not PluginMessage ()



  • hi,

    you can see in this thread that it's not possible with python.
    But maybe you can use another workflow. You can have another plugin asking for a directory, load every document on that directory, call your script that will work on the document, and close the document.

    You can only write the SceneHookData with c++ and that SceneHookData will call your python command so you don't need to rewrite it.

    Cheers,
    Manuel



  • @m_magalhaes, Hi!
    Thanks for the answer, I will try this and answer later.



  • You can only write the SceneHookData with c++ and that SceneHookData will call your python command so you don't need to rewrite it.

    Hi!
    Do you have examples of a plugin written with SceneHookData? I am more proficient in python than c ++ 😢



  • @m_magalhaes, Hi, can you answer me? plz



  • Hi,

    if my memory does not betray me, MSG_DOCUMENTINFO is being broadcasted to all nodes in the scene. So if you want to stay in Python, you could simply hijack a node type. One promising candidate could be PreferenceData, although I cannot guarantee that Cinema will also send document notifications to these nodes, since they are not part of a scene.

    Cheers,
    zipit



  • hi,
    Sorry for the delay.

    we have this example.
    The most important is ou c++ documentation

    you can see an example in the BaseDocument Manual

    
    class pc12835_scenehook : public SceneHookData
    {
    public:
    	static NodeData* Alloc() { return NewObjClear(pc12835_scenehook); }
    	Bool Message(GeListNode* node, Int32 type, void* data) override
    	{
    		if (type == MSG_DOCUMENTINFO)
    		{
    			DocumentInfoData* const msg = static_cast<DocumentInfoData*>(data);
    			if (msg == nullptr)
    				return false;
    			// switch message sub-type
    			switch (msg->type)
    			{
    				case MSG_DOCUMENTINFO_TYPE_LOAD:
    				{
    					ApplicationOutput("document is loaded"_s);
    					break;
    				}
    				case MSG_DOCUMENTINFO_TYPE_UNDO:
    				case MSG_DOCUMENTINFO_TYPE_REDO:
    				{
    					ApplicationOutput("undo or redo done"_s);
    					break;
    				}
    			}
    			
    			return true;
    		}
    		return SceneHookData::Message(node, type, data);
    	};
    
    };
    
    

    As @zipit said, the message is broadcast to all NodeData so using a PreferenceData.
    We have an example on github but you don't need all that code.
    After trying it myself, i couldn't make it work. It seems that the Message function is never called.

    Cheers,
    Manuel


Log in to reply