2
$\begingroup$

Question:

Is there a way, using geometry nodes, to retrieve the number of splines from a curve object? It seems to be a very straightforward question, but I cannot come up with a solution.

Details:

I'm not sure all of this is relevant, but just in case, here is exactly what I'm trying to do. I'm creating some text animations and I have some nodes that morph one curve into another. As the "Factor" from the group input moves from 0 to 1, the initial curve is transformed into the final curve. An example is shown morphing "1+2" into "3+4".

Morph one curve to another.

enter image description here

In this example, the initial curve "1+2" has 3 splines. The final curve "3+4" has 4 splines. To ensure the curve ends up looking right after the morph, I add a fourth spline to the initial curve before morphing. This is done by the nodes in the "Add Splines" frame. My issue is, depending on the curves involved I may need to add a different number of splines. I'd like to get the number of splines in the initial and final curves so that I can plug the difference into the "Amount" input of the duplicate geometry node. I can't figure out how to get this information though.

$\endgroup$
5
  • 1
    $\begingroup$ i wrote this often - and write it again: to attract more people to your question who don't want to rebuild your node tree manually - it would be a great idea to add your blend file so we can easily and quickly answer your question. $\endgroup$
    – Chris
    Feb 9 at 5:46
  • $\begingroup$ Thanks I appreciate it. Didn't realize I could do that and just figured out how. $\endgroup$
    – wgrenard
    Feb 9 at 5:55
  • $\begingroup$ thanks for your blend file - so you atttracted me to answer ;) $\endgroup$
    – Chris
    Feb 9 at 9:12
  • 3
    $\begingroup$ How about the node Domain Size? $\endgroup$
    – quellenform
    Feb 9 at 9:28
  • $\begingroup$ @quellenform This works perfectly as well, thanks. Can't believe I missed this one! $\endgroup$
    – wgrenard
    Feb 9 at 15:52

2 Answers 2

2
$\begingroup$

You can get the max spline index like this:

enter image description here

so just add 1 and you get the number of splines.

$\endgroup$
2
  • 1
    $\begingroup$ Thank you! I'd forgotten about the attribute statistic node and couldn't figure out how to easily get the max index. $\endgroup$
    – wgrenard
    Feb 9 at 15:50
  • $\begingroup$ you are welcome $\endgroup$
    – Chris
    Feb 9 at 17:20
2
$\begingroup$

Use the Domain Size node, in curve mode it has a Spline Count output.

The answer of Chris can't differentiate between 1 and 0 splines, since both will result in a max index of 0.

Using Domain Size

$\endgroup$
1
  • $\begingroup$ Yup, it is also more straightforward to use IMO $\endgroup$
    – Gorgious
    May 22 at 14:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .