SOLVED Is it possible to add layer solo to a new take through script?

Hey guys,

I am very new to C4D python.
Is there a way to add the layer solo option to a new take? I have A LOT of layers, manually dragging them to the take and setting the visibility for each one is gonna take forever.
I know you can create a new take with .AddTake, but I have no idea how to add layer solo override inside that new take and toggle them on.

Can somebody please help me!
Thank you so much.

Capture.PNG.png

Hi @ferdinand

Wow, first of all, I just want to say thank you so much for helping me out, you response have been extremely helpful!
Also, apologise for not properly tagging the post as well as not posting any code that I have written so far. As you can tell, this is my first post on this forum.

So I looked into the example script as well as links you sent to me, and I also checked out the module that you suggested. And I finally figure it out and get it to work after a few hours of digging in the documentation and playing with the example scripts. I am very excited now because this is literally my first Python script ever lol.

Again, thank you sooooo much @ferdinand! You really saved my day.

Best,
Sean1832

Hello @sean1832,

welcome to the Plugin Café and thank you for reaching out to us. Please read our Forum Guidelines which explain the procedures used in this forum. Your topic is missing the version of Cinema 4D you are using among other information. The version(s) should be expressed as tags of the topic, as lined out in the forum guidelines. I am sorry for pointing this out so bluntly, but the version is important. I assume you are using R23 from the screenshot.

What you want to do is certainly possible to do and for an experienced Cinema 4D developer also not that hard to do, but the API for the take system can be a bit daunting for beginners. I must also point out that we cannot provide code unless you have provided code with a concrete question.

From your description I understand that you what to create n takes for a document that contains n layers and then set the solo mode parameter of each such layer that is being wrapped by a take. I would first point to the official take system example scripts on GitHub which will explain most aspects of the take system API. There were recently also the topics How can I get a Layer's objects with Python? and Changing material projection in takes using Python here on Plugin Café, which talked about takes + layers and takes + parameters. There are also quite a few more threads in this forum on the take system, I would encourage you to search yourself for the ones that best fit your information needs.

You must principally iterate over all layers attached to a document and then add a take for the solo parameter of each layer. You can access the layers of a document with BaseDocument.GetLayerObjectRoot() and add takes with the c4d.modules.takesystem module. The central method in the take system module to add parameter overrides is BaseTake.FindOrAddOverrideParam. The solo mode of a layer is just a parameter as any other, it can be written with c4d.ID_LAYER_SOLO. The two threads I mentioned contain code with most of the building blocks for doing that. When you want more explicit help, you will need to provide some code of what you have done and where your problems are.

Cheers,
Ferdinand

Hi @ferdinand

Wow, first of all, I just want to say thank you so much for helping me out, you response have been extremely helpful!
Also, apologise for not properly tagging the post as well as not posting any code that I have written so far. As you can tell, this is my first post on this forum.

So I looked into the example script as well as links you sent to me, and I also checked out the module that you suggested. And I finally figure it out and get it to work after a few hours of digging in the documentation and playing with the example scripts. I am very excited now because this is literally my first Python script ever lol.

Again, thank you sooooo much @ferdinand! You really saved my day.

Best,
Sean1832

Hello @sean1832 ,

without any further activity before Wednesday, the 16.03.2022, we will consider this topic as solved and remove the "unsolved" state of this topic.

Thank you for your understanding,
Ferdinand