# Trim curve based on radius of control points using geometry nodes

I am trying to trim straight curves (actually converted from mesh edges) so that each endpoint is trimmed by half the value of its radius — so that if I succeeded, the new trimmed endpoints would be at the limits of cubes placed at the old untrimmed endpoints, each cube having the size of the radius of one of the old endpoints (somewhat like if the cubes were used to cut the curve using a boolean modifier). Unfortunately I haven’t found yet how to achieve that, the example file shows one of my various attempts.

On this screenshot the left cube size is 1, the right cube size 0.5, the curve left control point has a radius of 1, the right control point has a radius of 0.5. So I would expect the curve left end to be trimmed by 0.5 and the right end by 0.25.

That is a simplification to isolate my issue to submit here, but actually in various abstract geometric artworks I am currently designing https://skfb.ly/oMEUU lots of cube and curves are generated from the points and edges of a mesh, by a far more complicated geometry nodes setting with a variable radius field in order to create tubes of square section with cubes at intersections and turns.

• If you just trim the curve to meet the end of the cube exactly, the meeting faces will not be the same size... is that OK? Dec 4, 2023 at 19:47
• I know, this is another issue that I also wanted to solve but I wanted to simplify my question before submitting it. I expected that if someone found the solution to store the initial values of the end points radiuses and use them for trimming, maybe I could also use them for a "Set Radius" node inserted after the "Trim Curve" node. Dec 4, 2023 at 20:11
• If you wanted a match anyway, it might be simpler to construct the cubes from the trimmed ends by duplication and extrusion? Dec 4, 2023 at 22:02

In this particular case, I would not use the Trim Curve node if I were you, for two reasons:

1. When trimming, the values for the radii are interpolated, so you end up with incorrect values for Curve to Mesh.
2. You cannot create sections with it, you can only move the end points.

Therefore, I would suggest the following solution:

First split the edges so that you get individual segments. Before that, you capture the index of the points so that you can restore the radii after splitting.

Then simply move the respective end points along the tangents (or in the opposite direction) by the required value. In this way, you should be able to achieve the desired result even with continuous lines.

(Blender 4.0+)

• Thank you very much! I had guessed that my problem had something to do with Blender interpolating, along the curve between control points, not only the value of the radius but the values of named attributes that I tried to use in other attempts and you are absolutely right that the use of "Trim Curve" had to be dropped. My config is quite outdated and I still use Blender LTS 3.3.12 but I could apply your technique to my simplified example > i.stack.imgur.com/bhCEi.png Dec 4, 2023 at 23:52
• Beyond the "Offset endpoints" section, the rest of your solution, splitting edges and instancing cubes, is almost what I already did in my more complex design but didn’t include in my example. If you are curious to see the solution in use, here it is > blend-exchange.com/b/2exsDjSG Dec 5, 2023 at 0:18
• @robinfredericf Very nice patterns, I love it, well done! Dec 5, 2023 at 0:36
• Replacing the Grid + Mesh to Curve with a Quadrilateral is also very useful, not only it saves one node but also it generates tubes with already correctly oriented normals — with my initial setting I had to add a Flip Faces after my Curve to Mesh. Dec 5, 2023 at 0:59