How can you divide a line according to these mathematical parameters. The red distance should be 300mm and the green distance should be <600.
Can you for example put a mathematical formula in a code block for example;

First of all the credits for this solution go to @Kulkul

What you do is
Select a few nodes in your graph and right click, then go for Node to Code.
This will give you the Designscript equivalent of the nodes.
It works best with the out of the box nodes.
Then study what you see.
If you do this regularly Designscript will get easier to read and you have made the first steps.

you can also read the Designscript guide and documentation.

I reccomend retyping them afterwards, reducing the number of lines by using inline code when possible and changing out variable names so they make sense. This will help you learn better and allow for easier re-work in the future.