2

I am trying to scale a mesh line and then subdivide it every 2cm.

I know this can be achieved by first converting to curve and using resample and reconverting to mesh.

But is there any other way of doing this? I attempted by trying to capture the edge positions after scaling and creating a new line, but no luck. My attempted node network is in the screenshot.

Thanks in advance

enter image description here

R M K
  • 388
  • 4
  • 14
  • 1
    Can we ask why? The other methods that I can think of are very long-winded, and involve replacing the existing line with a constructed duplicate, anyway. You have to generate vertices, somehow. – Robin Betts Oct 04 '22 at 09:55
  • 1
    @RobinBetts, basically, i was assuming that conversion of objects from one to another is a resource intensive operation. Hence i thought, i can get some alternatives. "Construction of duplicate" is how i had attempted in my screenshot. The place i got struct, is how to transfer the vertex positions. – R M K Oct 04 '22 at 13:53
  • 3
    Wow, that's an interesting color scheme ! – Gorgious Oct 04 '22 at 14:26
  • This looks like one of those silly Jachym Michal's questions. Is your Mesh line always a single edge? If not, then you need to obtain the endpoints by Transfer Attribute to read the coordinates of the indices 0 and Domain Size: vertices -1. Then if you don't want to spawn another object, you can subdivide it first and remove the excess vertices. You can then lerp between the endpoints using Mix RGB node, you could also clamp and merge by distance to get rid of the excess verts... – Markus von Broady Oct 04 '22 at 14:53
  • 1
    @Gorgious .. that would be 'interesting' in the same sense as the blessing: 'May you live in interesting times' – Robin Betts Oct 04 '22 at 15:19
  • @MarkusvonBroady sad to note that you find this question silly. But i rather ignore that portion and prefer to learn from the other portion of your comment.

    Yes, as you would note in the screenshot, my mesh was created with Mesh Line with count 2 and has only a single edge

    – R M K Oct 04 '22 at 16:32
  • @RMK just to be sure, it wasn't derogative, silly as in funny. A tad ridiculous no doubt. I did look at your screenshot, however the question is if the screenshot only uses the Mesh line of verts=2 to showcase the problem, or if you for some reason first create a Mesh line of two verts to then later recreate a Mesh line of more verts, rather than directly create the latter... – Markus von Broady Oct 04 '22 at 16:50
  • @MarkusvonBroady ah, now i see your point and understood what i missed explaining. I am creating the Mesh Line with 2 points (locations of 2 objects) so that i can scale it before subdividing. I will have to expose the scaling as a user parameter. After the scaling, i want to subdivide by 2cm. This whole network is part of a bigger visualization project. I wanted to use this use case as an opportunity to learn how to transfer the scaled vertices of a constructed geometry and create a new geometry. That is where i got the error (red lines). – R M K Oct 05 '22 at 04:30

2 Answers2

3

You can't connect a field output into a constant input, because the former represents a list (or a generator, if you know Python) of values, while the latter represents just a single value. You can use an Attribute Statistic node to convert between the two. However, in your case you simply want to scale your endpoint vectors, which will have the same effect as using the Scale Elements node:

If you want to specify an offset, you can do that, but then one of the endpoints will only define a direction - you can't eat your cake and have it too:

You could calculate how many vertices should there be for the given endpoints and a desired offset, but then you have to decide if you're willing to go beyond the endpoints to get the offset, or adjust the offset slightly...

Markus von Broady
  • 36,563
  • 3
  • 30
  • 99
  • Hey, the 2 options you provided are really good. But the real icing on my "cake" was your explanation about why my node network was failing. Because of that, i managed to fix the issue with my original node network. Thanks for that. But having said that, i would have to agree with you and @RobinBetts that it is a long-winding route compared to just use object conversion to curves. But atleast, i have learnt alternate approach that can be used in some other situation. – R M K Oct 05 '22 at 16:19
3

Here is my node network inspired from @MarkusvonBroady explanation. I agree that this may not be as elegant approach as converting to curve and resampling. But it gets the job done and works in Blender 3.3

enter image description here

This can be further simplied to

enter image description here

R M K
  • 388
  • 4
  • 14