Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Run script on File->Open

    Scheduled Pinned Locked Moved SDK Help
    4 Posts 0 Posters 350 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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).

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post