UNSOLVED get length of stroke


I am trying to write a script for the sketch material that makes the "pixel" mode in Draw Speed in the Animate tab work similar to the "completion" mode. What I mean by that is that I want to be able just like in the completion mode to keyframe the beginning and end of the drawing process. But the pixel mode only lets me set the start frame and the speed in pixels.

So the goal is to have the script calculate the speed required to make the drawing end at frame x.
The reason for doing this is that if I have objects with multiple different strokes of different lengths, the drawing speed varies significantly which doesn't make for a nice aesthetic in the end.

I know there has to be some place in C4D where the length of each stroke is stored in order for the completion mode to work. So the only question is if and how I could access this value in my python script.

Thank you.


I'm not sure to understand, you have one material for each stroke length?

After looking at the code, the problem is that you don't have access to each of those length. You could calculate them, you must calculate them in screen space/resolution, apply some ratio/formulas that have many cases, for example if the render is on portrait or landscape, and retrieve the speed we should set to travel that distance in xx frames.

If you have some camera animation, I'm not even sure if it's possible. Could you provide a scene so we could reproduce what you want to achieve?


Thanks for the reply

@m_magalhaes said in get length of stroke:

I'm not sure to understand, you have one material for each stroke length?

You are right, I didn't consider that I can only set one speed per material which in my case corresponds to one object.
In this case I want to obtain the length of the longest stroke in order to have the drawing process be finished on frame x. Besides that everything stays the same.

I found out that it is possible to use python as a modifier for thickness, color and opacity of the strokes. In this context "StrokeLength" is accessible as a predefined variable.
So with that as a starting point the question becomes how to make this variable accessible outside of the modifier context so I can use it in a regular python script.

Grateful for any suggestions.



Sorry it's not possible for the moment to access that information outside those contexts.


Hello @InterfaceGuy,

without any further questions, we will consider this topic as solved by Monday, the 25th and flag it accordingly.

Thank you for your understanding,