Is it possible to change active view via python but "c4d.CallCommand(13640) # Toggle Active View"?
Because "c4d.CallCommand(13640) # Toggle Active View" is used with a click on the view. I can not use python code to change a certain view to be active.
I want to change active view via the view ID from "range(doc.GetBaseDrawCount())". But I can not find the relevant APIs.
I can get the active view from "doc.GetActiveBaseDraw()" but there are no ways to set the active view.
Thank you for reaching out to us. In short, what you want to do is unfortunately not possible.
To unpack things a bit, I understood your question as such that you have multiple view panels in your layout and each view panel contains multiple views. The screen below shows two view panels with four views each for example.
You then want to toggle a view panel from showing all its views (depending on the panel layout) to singular one, e.g., "minimize and maximize" the Perspective view in the second panel. For that you wanted to use c4d.CallCommand(13640) and therefore need to set the active view (the view with the grey border).
Internally, there is a non-public method called BaseDocument::SetActiveView which handles setting the selected viewport and one has more or less all tools in the Python SDK to replicate it (you more or less just have to set BIT_ACTIVE and send some messages). And while doing this will have some effect on the selection state of viewports, it will not be identical to what you can achieve with mouse interactions, and running then your CallCommand(13640) on such 'semi-selected' viewport will not have the desired effect.
In the end, the viewport selection state is bound to a very specific call chain in our internal API. Which is probably the reason why the method BaseDocument::SetActiveView remains non-public.
FYI: This is not a Python issue, the same applies to C++, I tried it there too, to the same effect.