UNSOLVED Need help making this script

Hi, I am trying to make a python script for Cinema4D to help me with my repetitive task. I have a lot of models to optimize the same way. Look at the leaf in the picture:

5b0afac8-7693-4fa4-828d-2022f8e98a5f-image.png

I want to optimize the leaf by reducing the number of vertices on the circumference. I was doing it manually for a while but I realized there is a way to automate the task.

What I have in mind is iterating each edge of the circumference and deselecting each point that has a high angle with it's neighbours. If the angles are low with neighbours, the point would stay selected so I can delete it, thus reducing vertices that are not needed to keep the general shape and uvs of the leaf.

So the script should work with a preselected loop, doing dot product on each neighbouring edges and compare them to a treshold value, then deselect them accordingly.

The result should look something like this:

f794d5f9-4295-40ef-bd56-31e64b1dfb5d-image.png

I know the results won't be always perfect with an automated solution, but efficiency is more important than looks here.

I've been trying to make this script for a while with no sucess. Python has not been good to me..
The most I've managed is a script that discards every second selected vertex randomly..

Could someone make this script for me? I'd be willing to pay some money for this.

This post is deleted!

Hello @rgi,

thank you for reaching out to us and welcome to the Cinema 4D development community. Please take a look at our Forum Guidelines, as we do require postings to follow a certain form. Your posting is most importantly missing the required tags describing the programming environment, the targeted version(s) of Cinema 4D and the targeted operating system(s).

About your question: We have a series of example scripts on polygon reduction GitHub which might be useful to you. The one most relevant for you is probably polygonreduction_vertexlevel_r19.

Cheers,
Ferdinand