UNSOLVED Is it possible to change the mode of the Viewport without callcommands?

It required to make a change of the mode type of the Viewport, when doing it I wondered if there was any way to do the same function without using callcomands.
Is it possible?

Hello @jh23,

Thank you for reaching out to us.

A viewport in Cinema 4D is represented by the types BaseDraw and BaseView (the former is the more important type) and its inheritance chain is C4DAtom -> GeListNode -> BaseList2D -> BaseView -> BaseDraw. So, viewports are BaseList2D as most central enteties in the classic API and can be modified with paramater access, e.g., myNode[SOME_ID] = someValue. The IDs can be found in multiple ways as explained here. The BaseDraw symbols can be found here here.

It is not fully clear to me what you mean by the "mode type" of a viewport. I have provided a small example script which demonstrates some likely candidates.


The result:

The code:

"""Simple example that modifies all the viewports of a document.

import c4d

def main(doc: c4d.documents.BaseDocument):
    """Modifies all viewports of the passed document #doc.
    # Iterate over all 'BaseDraw' instances, i.e., viewports of the document. There are also
    # specific methods to retrieve the active or render BaseDraw of a document. See the Python 
    # BaseDocument documenation for details.
    for viewPort in (doc.GetBaseDraw(i) for i in range(doc.GetBaseDrawCount())):
        # A BaseDraw is a C4DAtom -> GeListNode -> BaseList2D as any other node in Cinema 4D and
        # almost all of its attributes are expressed as paramters which can be read and written.
        # The parameters can be discovered as usual with the console or Python documentation.

        print (f"{viewPort.GetName()}: {viewPort}")

        # Set the shading mode to "Gouraud - Lines"

        # Set the wire mode to "Isoparms"

    # Add an update event for Cinema 4D.

# Execute main()
if __name__=='__main__':
    # #doc is predefined in a script as the active document.

Hello @ferdinand ,
Thanks for the explanation, but in my case I meant this:
I need to make changes to these options, although it is true that they can be done by callcomands, I am interested in knowing if it is possible to avoid their use, I did some research, but didn't find much, I guess it's possible, and I probably didn't understand.
still thank you very much for your contribution

Hello @jh23,

the editor mode of a document can be set with BaseDocument.SetMode and read with its counterpart BaseDocument.GetMode().


import c4d

def main():
    """Toggle the document between point and polygon mode.
    if doc.GetMode() == c4d.Mpoints:

# Execute main()
if __name__=='__main__':

Hello @ferdinand
Thank you very much, I had no idea about that, I did know that Mpoints or Mpolygons existed, but it always related to me with ViewportSelect, this answers my question, I will investigate more about this.