GetWorldContainer to change preferences [SOLVED]

On 08/06/2015 at 08:41, xxxxxxxx wrote:

I want to change Settings in Programm-settings.

This is what I used. But this is not working. What else do I miss?

            ma = c4d.GetWorldContainer()
            ma[c4d.PREF_OPENGL_ANTIALIAS]=2

On 08/06/2015 at 08:44, xxxxxxxx wrote:

Hi Holger,

try the same with GetWorldContainerInstance() instead. In your code you are only changing a copy of the world container.

On 08/06/2015 at 08:48, xxxxxxxx wrote:

Stange...still not working. Do I need to import any modules?

This is my complete Script. I want to set OGL AA to 0.

import c4d
from c4d import gui
#Welcome to the world of Python
  
  
def main() :
    ma = c4d.GetWorldContainerInstance()
    ma[c4d.PREF_OPENGL_ANTIALIAS]=0
    
    
    c4d.EventAdd()
if __name__=='__main__':
    main()

On 08/06/2015 at 08:55, xxxxxxxx wrote:

Sorry, Holger,

I didn't pay enough attention. You also want to use the correct constant:
WPREF_OPENGL_ANTIALIAS
(note the W in the beginning)

On 08/06/2015 at 09:05, xxxxxxxx wrote:

Thanks Andreas for the instant support, That is working now. 
I am sorry for all my question. I am working on a huge Scriptcollection I want to port to python and there is a lot of questions.

On 08/06/2015 at 09:07, xxxxxxxx wrote:

No need to apologize.
That's what we are here for.

On 25/01/2016 at 07:43, xxxxxxxx wrote:

Hello guys!
Tell me please,
how to use same code to change Team Render Machine Name

import c4d
from c4d import gui
#Welcome to the world of Python

def main() :
    ma = c4d.GetWorldContainerInstance()
    ma[c4d.PREF_NAME] = "NewName"
    c4d.EventAdd()
    
if __name__=='__main__':
    main()

On 26/01/2016 at 03:31, xxxxxxxx wrote:

Hi Mike,

welcome to the Plugin Café forums :slightly_smiling_face:
At first I'd like to ask you to please open a new topic for non-related questions. I know, sometimes it's a thin line between related and non-related and may even lie in the eye of the beholder. I'd say, if in doubt, rather open a new thread. But no big deal, still happy to have you here.

For many modules the preferences contain a sub-container with the preferences values.
So in your case it looks like so:

  ma = c4d.GetWorldContainerInstance()
  np = ma[c4d.PREFS_PRI_NET]  # get the net render sub-container
  np[c4d.PREF_NAME] = "NewName"
  ma[c4d.PREFS_PRI_NET] = np  # store the changed container to preferences
  c4d.EventAdd()

On 26/01/2016 at 04:09, xxxxxxxx wrote:

Thank you! :clap: