Blending Take Overrides with a Python Script

Photo of Rick Barrett

Instructor Rick Barrett

Share this video
  • Duration: 04:17
  • Views: 2956
  • Made with Release: 17
  • Works with Release: 17 and greater

Extend Takes via Python to quickly blend between Override Values.

The Take System in Cinema 4D Release 17 includes an extensive C++ and Python API. In this tutorial, you'll see how the Python API can be used to create a script that blends between the override values of two takes. This is useful especially when experimenting between different values for dynamics simulations.



- Someone asked me online about the API for the Take system, and rather than go into the nitty gritty of the API itself, I want to show you something that I've already created using the Python API for the Cinema 4D R17 Take system. You might remember the scene file that Donovan Keith created in his call series, and he was showing different iteration levels of the clock tag, and how those affect how the clock behaves. Well he had to do this in a very manual way, creating individual copies of the object for each iteration level. With takes, we can do this much more simply. So first of all, I'm going to go into the Take system and create a new take, and we're going to call this Iterations 10, because that's what we're going to do with it. So we'll go into the clock tag, and go into the tag tab, and right-click to create an override. And make sure this is set to Iterations 10. Now we'll go in and create another new take, and call this Iterations 100. And we're going to do the same thing, go into the tag, right-click to create an override, and now we're going to set the iterations value to 100. So now we have two different takes, one with the iterations value at 10, and one with the iterations value at 100. And that's kind of handy, in and of itself. But where my script comes in, is that I've created a script that allows you to blend these values. So you can get all of the values between 10 and 100. So if I just select two takes, and the script only works if you select exactly two takes, and I hit execute, it's going to ask me how many blends I want. I'm going to say eight, and hit okay. And now you can see that it's created individual takes for me, with the iterations value at 20, 30, 40, 50, 60, 70, 80, 90, and we already had 100. So I think that's a super cool feature, if you need to test what value is going to be specifically the right value, for especially a dynamic simulation like this. Now this this can also work for multiple parameters. So if I go ahead and delete all of these intermediate takes that I just created, and I'll go activate the Iterations 10 take. And I'm going to go ahead and add another override for stiffness, and I'll leave that at 10% as well. And then we'll go down into the next take, and we'll override that, and set the stiffness to 100%. And now if we go ahead and select both of them, and we'll go ahead and run that script again, we'll do eight. Now we have the blend on both the iterations attribute, as well as, on the stiffness attribute. So this is, I think, a really handy script, and for those of you who are the gear heads, and want to see how it works, I'll just quickly show you what is going on here. The first thing we're doing is getting the take data element for the document, that's sort of the container that holds all the Take system information, and then we're getting the selected takes. We check to make sure that there's only two takes selected, and if not we error out. Pop up a dialogue to ask how many blends the user wants, we're going to use a list here to store the blends. And here what we're doing is getting the first selected take, and getting all of the overrides that have to do with that take. I'm going to loop through those, and get all of the description IDs, all of the individual attributes in the attribute manager that relate to that override. As we loop through those we're going to see if the same override exist in the second selected take. If it does, I'm just adding the object, the description ID, and the first and second values into a list, and then I go through down here, and create takes for each intermediate blend, and create overrides based on a blended value between the first and the second value. So as you can see the takes API in Python is quite expensive, which is really exciting, because developers are going to be able to do some awesome stuff with this new system in Cinema 4D R17.
Resume Auto-Scroll?