SOLVED startup script in R23 not working anymore

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.

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

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

hi @ferdinand
thank you very much for your response!

the python_init.py does the job perfectly :)

great support, thanks a lot!

best,
marc.