Run script on File->Open



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 16/04/2008 at 17:42, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   10.506 
    Platform:   Windows  ;   Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    Hey there,
    I would like my plugin to run every time the user opens up a new c4d scene (Both File->Open and double-clicking a file from the OS). Is there a specific hook for this, or do I have to listen in a background thread?
    Searched the forum and the SDK pretty heavily and couldn't find anything, hopefully I'm not wasting anyone's time.

    Thanks!
    Chris Kelley



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 16/04/2008 at 20:02, xxxxxxxx wrote:

    Depends upon what you want to do. There is a message MSG_MULTI_DOCUMENTIMPORTED as well as MSG_DOCUMENTINFO sent to the document and all children. The plugin cannot react before Cinema 4D loads and registers plugins (i.e.: no preload conditions can be coded).

    The problem is that you want to run your plugin on this condition (so it won't have received any messages). You probably want a SceneHook plugin in addition for this purpose. A Message plugin may also be possible but it only receives CoreMessages (not messages like those received by other plugins through the overriden Message() method).



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 17/04/2008 at 03:20, xxxxxxxx wrote:

    AS Robert said the best way would be to use a SceneHook and check for MSG_DOCUMENTINFO.

    here a little example:

    > \> #include "c4d.h" \> #include "c4d_symbols.h" \> \> \> class MyHook : SceneHookData \> { \>      public: \>           virtual LONG Execute(PluginSceneHook \*node, BaseDocument \*doc, BaseThread \*bt, LONG priority, LONG flags); \>           virtual Bool Message(GeListNode \*node, LONG type, void \*data); \> \>           static NodeData \*Alloc(void) { return gNew MyHook; } \> }; \> \> LONG MyHook::Execute(PluginSceneHook \*node, BaseDocument \*doc, BaseThread \*bt, LONG priority, LONG flags) \> { \>      return EXECUTION_RESULT_OK; \> } \> \> Bool MyHook::Message(GeListNode \*node, LONG type, void \*data) \> { \>      switch(type) \>      { \>           case MSG_DOCUMENTINFO: \>           { \>                DocumentInfoData \*info = (DocumentInfoData\* )data; \>                if(info->type == MSG_DOCUMENTINFO_TYPE_LOAD) \>                { \>                     GePrint("document loaded"); \>                } \>           } \>      } \> \>      return TRUE; \> } \> \> #define ID_MYHOOK 1022492 //use your own unique plugin ID \> \> Bool RegisterMyHook(void) \> { \>      // decide by name if the plugin shall be registered - just for user convenience \>      String name=GeLoadString(IDS_MYHOOK); if (!name.Content()) return TRUE; \>      return RegisterSceneHookPlugin(ID_MYHOOK,name,0,MyHook::Alloc,EXECUTION_RESULT_OK,0); \> } \>

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 17/04/2008 at 04:00, xxxxxxxx wrote:

    Thank you fellas for the quick and detailed replies. Big thanks for the code sample, Matthias.


Log in to reply