Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    startup script in R23 not working anymore

    Cinema 4D SDK
    r23 python
    2
    3
    488
    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.
    • M
      marc_angele
      last edited by marc_angele

      hello guys,

      i finally updated to R23 and have now an issue with my startup code.
      to load and set some variables i used the $g_prefspath/python37/maxon_generated/__init__.py file.
      in R21 it worked perfectly. now in R23 the script didn't execute anymore.
      i tried to delete the library and tested it on different machines.

      does some of you have an idea?
      or is there a better solution to execute some python code at startup?

      thank you for any help!
      best,
      marc.

      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by ferdinand

        Hi @marc_angele,

        thank you for reaching out to us. Your problem is caused due to a change of how Python is integrated with R23+ compared to R20.

        • First of all, you are not really supposed to modify {USERPREFS}/python37/maxon_generated/__init__.py, as this is a file for internal usage. So this was never a feature in the first place 😉
        • You can however still modify it, and it will still work as long as you have a plugin installed which imports the maxon package. Your code will be then executed when this plugin imports the package.
        • Better solutions would be however:
          a. Create a file called python_init.py as{USERPREFS}/python37/python_init.py. It will mostly work like an __init__.py, here you can find its (slightly outdated) documentation.
          b. Implement some kind of plugin and implement PluginMessage() and hook into C4DPL_INIT_SYS or C4DPL_INIT which are very early points to execute code in the boot up of Cinema 4D. Both for python_init.py and PluginMessage() applies that due to this early stage of the boot-up of Cinema, you won't have full functionality of all modules yet.

        For more complex tasks you might have to run a script with c4dpy before you actually start Cinema or postpone your code to a later point in PluginMessage.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • M
          marc_angele
          last edited by marc_angele

          hi @ferdinand
          thank you very much for your response!

          the python_init.py does the job perfectly 🙂

          great support, thanks a lot!

          best,
          marc.

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