2
$\begingroup$

I'm trying to separate the middle-section of a curve (points 3 and 4 in my example), apply some transformations to it, and then merge it back with the original curve. I've gotten to the point where I'm happy with the result, except that after joining the curves back, the original curve is still present because it's connecting the wrong sections of the curve (points 2 and 5 get connected, selected points 3 and 4 are connected with each other but not the main curve). I'm not sure how I can avoid this, does anyone have any suggestions?

Node setup (minimal example, I'm instancing cubes on the curve points for visualization purposes). What I would like is to generate the blue line as a curve.

Node setup

Current behaviour:

Current behaviour

Desired behavior:

Desired curve behaviour

$\endgroup$
3
  • $\begingroup$ Why separate? Just use the endpoint selection as an the input selection for the set position node and forgo the separate andnjoin node s $\endgroup$ Commented Sep 28, 2024 at 14:43
  • $\begingroup$ @Leander perhaps OP is resampling part of the curve. $\endgroup$ Commented Sep 28, 2024 at 14:56
  • $\begingroup$ I posted a minimal example, to keep the screenshots tidy. I split the curves after using a raycast node to check if something is inside a target object. Then, I resample points inside the object, and select the position of the first and last point inside the object. This gives a 3D vector which is crossed with a vector generated from the target object's rotation. Together, these decide the projection direction. The actual ray direction gets spread out over a 180 degree arc (+90 and -90 degrees wrt the proj dir), using a map range with the curve indices. This feeds into a second raycast. $\endgroup$ Commented Sep 28, 2024 at 18:17

1 Answer 1

2
$\begingroup$

Perhaps easiest is to split into three, join back, convert to points and back to a curve. Just ensure the link order in "Join Geometry" is correct. If you have multiple splines, you can capture spline index ("Curve Info" is a custom group available in vanilla Blender, but the part I'm using is just Index → Evaluate on Domain: Spline) and use it as group ID in the "Points to Curve":

"Do something" above simply resamples a curve to 3 points.

Dynamic (variable) number of parts

You can't use "Separate Geometry" node to separate a curve into more than two parts. This is because a curve, unlike mesh, doesn't store info on connections between points (edges), it just stores points in order, and the connections are implied by that order. The only exception is the info if the first and last point are connected, which is called "cyclic[ity]". So for splitting a spline to more than 2, you need to convert it to mesh, then split verts (splitting edges will duplicate points!), and convert back to curve.

Also beware converting mesh to curves will ignore single vertices, even though you can make single-point splines. So if that's ever a problem, you need to use "Vertex Neighbors" to detect such situation and duplicate them temporarily (resample these splines back to 1 after conversion).

Then as above, join the geometry together, but avoid joining what used to be separate by using the captured "Curve Index". Additionally, capture the point indices to keep the order right.

Notice how the captured index isn't float, which makes the resampling interpolation produce a lot of duplicates - this is not a problem, because according to the docs

Weight

If the curve contains more than one Point, the Weight of each Point is used to define the order of all points in curve via sorting. The goal of sorting is to have points with the minimal Weight value at the start of curve and the maximum Weight at the end of curve.

Note

If points of curve have the same Weight value, the order will be the same as its original relative location. Without any Weight and Group ID inputs, each point will have the same indices in the curve.

I actually don't quite understand this, I Think they should just say the 2nd sorting criterion (a tie-breaker) is the index…

So here's the setup:

$\endgroup$
10
  • $\begingroup$ Thank you, this is close, but it's exploiting the fact that I simplified my example too much. The selected points in my setup are using a raycast node that checks if the points are inside a different object. See this node example: LINK which has this (incorrect) curve output: LINK. Is there a way that your method can work for this setup? I removed the instances on points and switched to your viewer node method. $\endgroup$ Commented Sep 28, 2024 at 16:40
  • $\begingroup$ @PvB can be done, but why are you even separating here? "Set Position" has "Selection" input that you're even using. $\endgroup$ Commented Sep 28, 2024 at 17:07
  • $\begingroup$ It's still a minimal example. I have an elaborate node setup (with a 2nd raycast node, amongst other things) that allows me to evenly wrap around the target object. I'm splitting the curve so that I can resample, get the number of points inside the mesh, and combine this with the indices to evenly spread out the ray directions over a 180 degree arc. This works, but when combining it back with the other section of the curve, I get both the projected curve and the original curve. Here's a screenshot of the problem (using a sphere not a cylinder) link $\endgroup$ Commented Sep 28, 2024 at 18:06
  • $\begingroup$ " I'm splitting the curve so that I can resample" - ah, so I guessed right! OK I'll update the setup then. $\endgroup$ Commented Sep 28, 2024 at 18:40
  • $\begingroup$ @PvB see edit.. $\endgroup$ Commented Sep 29, 2024 at 12:58

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.