thank you for reaching out to us. Please remember to follow the forum guidelines and add the required tags to your posting, describing the OS, programming environment and version of Cinema 4D you are using.
The world container unfortunately does not contain all user settings. Under the hood, preferences are largely organized in preferences plugins which carry their settings on the node representing that plugin. So, to read and write such settings, one must retrieve and interact with these plugins. The code at the end of the posting goes into the technical details.
"""Example for reading and writing arbitrary parameters in the Preferences
dialog of CInema 4D.
The world container unfortunately does not contain all user settings. Under
the hood, preferences are largely organized in preferences plugins which
carry their settings on the node representing that plugin. So, to read and
write such settings, one must retrieve and interact with these plugins.
As discussed in:
# The id of the preferences plugin node, there is no symbol for it, so we
# have to hard-code it. I just happened to know that id. The only way to get
# hold of it, is to search all plugins by their name via c4d.plugins.
# FilterPluginList and look for plugin names that look promising. I.e.,
# something that contains "preferences" or "prefs" in this case. That is
# at least how I usually do it when I have to dig out some internal node.
ID_PREFERENCES_NODE = 465001632
# Get the preferences plugin node or bail if we failed to retrieve it.
prefs = c4d.plugins.FindPlugin(ID_PREFERENCES_NODE)
if not isinstance(prefs, c4d.BaseList2D):
raise RuntimeError("Could not access preferences node.")
# The global settings node which primarily carries references to other
# specialized settings nodes.
# Code I did use to figure out where stuff is. The preferences are
# basically a bunch of connected PreferenceData plugins. We now need
# to find the node that represents the viewport tab. The code is not
# required for what you want to do, I just left it in so that it can be
# understood how I did came up with the magic numbers below.
for bc, descid, _ in prefs.GetDescription(0):
name = bc[c4d.DESC_NAME]
if "viewport display" in name.lower():
print(name, descid, prefs[descid])
# It will print something like this:
# Viewport Display (465001625, 1, 465001632) None
# Viewport Display ((465001625, 1, 465001632), (888, 133, 465001632))
# <c4d.BaseList2D object called Viewport Display/Viewport ...
# So, the second thing is what we are looking for.
descIdViewportSettings = c4d.DescID(
c4d.DescLevel(465001625, 1, 465001632),
c4d.DescLevel(888, 133, 465001632))
viewportPrefs = prefs[descIdViewportSettings]
# We could have also searched for the viewport settings plugin right away
# in the plugins of Cinema as described at the top. 465001625 is its ID, so
# one could also call c4d.plugins.FindPlugin(465001625) to get the viewport
# plugin right away.
# The viewport settings node.
# And your value.
# Since this is just a node, a BaseList2D, we can also write values.
# Set the axis scale to 50%.
viewportPrefs[c4d.PREF_VIEW_OBJECTAXIS_SCALE] = .5
# Push an update event to Cinema 4D.
if __name__ == '__main__':