# Thread: How to weld points to average but without welding

1. ## How to weld points to average but without welding

Hi, I would like to move points to their average position. There is a weld to average command but I don't want the points to be welded, just moved to their average position based on some threshold value.

2. Only thing that comes to mind is to select the group of 4, and just size it down, using "AC:Selection" as the action center.

In some cases I imagine Point Normal Move could be used to scale many sets of 4 at the same time.

3. I know but I need to do this massively on the entire model, this would be too time consuming.

Point normal move would work if all points were at the same distance from their averaged center, but this is not the case.

4. if you could create a spline at the centre of it with a point in the middle of each of the 4 points in the back ground (you would probably have to make a copy of the object then hand weld average each set of 4 so maybe still a bit of time needed) and then I think "shrink wrap" has a nearest point option that may work

5. UVing a Tree...?

maybe there is a plugin for it?

there is the plugin Edge Opener, but that works the other way around

(hmm, Edge Opener is 32bit only it seems, even though DStorm page says 32/64)

6. Does this require anything special, like it has to respect islands of points (as in, you've selected multiple islands, and need each one to collapse, or is it the simple case, where your selecting a large group of points to collapse into a single point (but not weld)? The solution, for lscript, is trivial.
Code:
```@script modeler
@warnings off
@name Snap to Avg.

main
{
//debug();
totPntVal = < 0, 0, 0>;
selmode(DIRECT);
pntCnt = pointcount();
if(pntCnt == 0)
{
error("No points selected!"”);
}
editbegin();
for(currPnt = 1; currPnt <= pntCnt; currPnt++)
{
currPntVal = pointinfo(points[currPnt]);
totPntVal = totPntVal + currPntVal;
}
pntAvgPos = <totPntVal.x / pntCnt, totPntVal.y/pntCnt, totPntVal.z/pntCnt>;

for(currPnt = 1; currPnt <= pntCnt; currPnt++)
{
pointmove(points[currPnt],pntAvgPos);
}
editend();
}```
Cut and Paste this to a text editor, then save it as <filename>.ls. You can add it as a plugin via Lightwave, and then give it a button via the menu editor.

This is an old script, and I can't even take credit for it. A good portion of the code is shared between weld, weld pairs, weld average, and weld average pairs scripts, the main difference is in how the points get moved before being merged.

Hope this at least (partly) helps.

7. Why not just select the points, weld averge then unweld unless you don't want them exactly at the same point.

8. Kryslin, is native WELD AVERAGE a script??

9. No, it's an actual compiled plugin. However, it is easily duplicated in lscript. The redone weld/weld avg/weld pairs/weld pairs avg scripts all come from the original lscript documentation, about how one can get rid of the pesky message box that used to pop up every time you used weld.

The lscript versions do have a small problem - if there is any difference between the points being welded (like morph maps), it won't weld them. Move them, yes, but not weld them.

I think Iain_r's suggestion, however, might be faster for large numbers of points.

10. not sure if this could be of help,...

11. Originally Posted by Kryslin

...The lscript versions do have a small problem - if there is any difference between the points being welded (like morph maps), it won't weld them. Move them, yes, but not weld them....
.
That sounds exactly like what the Original poster wanted.

Erikals, I don't think anybody is talking about UVs... Iain's suggestion might not work because you are merging 4 points that come from quads but they turn into triangles, so unwelding gives you triangles not quads. (I'm not sure what the OP had in mind but my guess is that he needed to stay in quads)

12. That sounds exactly like what the Original poster wanted.
yep, think that is the solution.

regarding UV's, it looks like from the original picture he is UV mapping a tree? ...not quite sure.

13. Originally Posted by Kryslin
No, it's an actual compiled plugin. However, it is easily duplicated in lscript. The redone weld/weld avg/weld pairs/weld pairs avg scripts all come from the original lscript documentation, about how one can get rid of the pesky message box that used to pop up every time you used weld.

The lscript versions do have a small problem - if there is any difference between the points being welded (like morph maps), it won't weld them. Move them, yes, but not weld them.
That is NOT a bug, that's a definite FEATURE: I use a m.map named "NO_MERGE" to preserve points from inadvertant merging.
I think Iain_r's suggestion, however, might be faster for large numbers of points.
I rather moderated my question because iain_r's method was the first that occurred to me, if there were simple LScript commands for WELD_AVERAGE immediately followed by UNWELD. I'm not sure what the OP's application for this routine is, but the illustration seemed to indicate a desire to collapse branches or tentacular-type meshes to a central spline. This I think would require a threshold value to avoid collapsing far-distant points, although a real pro routine would also avoid re-curve situations.

Hmmmm... do we already have a tool that would step down via NEXT LOOP a mesh, collapsing subsequent loops??? That might be pretty convenient for use with tree structures.

14. Originally Posted by jeric_synergy
That is NOT a bug, that's a definite FEATURE: I use a m.map named "NO_MERGE" to preserve points from inadvertant merging.

I rather moderated my question because iain_r's method was the first that occurred to me, if there were simple LScript commands for WELD_AVERAGE immediately followed by UNWELD. I'm not sure what the OP's application for this routine is, but the illustration seemed to indicate a desire to collapse branches or tentacular-type meshes to a central spline. This I think would require a threshold value to avoid collapsing far-distant points, although a real pro routine would also avoid re-curve situations.

Hmmmm... do we already have a tool that would step down via NEXT LOOP a mesh, collapsing subsequent loops??? That might be pretty convenient for use with tree structures.
Ok, now someone's got me curious. I think it could be done. I think next loop and previous loop are CMDSEQ operations (and can be called from lscript), but the problem I forsee is detecting when the operation fails. I'll have to read up on cmdseq() and see if it returns a value or not... Drat, cmdseq() is one way. You can invoke another plugin, but not get information back...

15. Originally Posted by Kryslin
... Drat, cmdseq() is one way. You can invoke another plugin, but not get information back...
Well, the WELD_AVERAGE code is, as you've demonstrated, no big deal, so you wouldn't have to invoke another plugin. That would be elegant, but is apparently not to be.

I'd think (for certain low values of 'think') that branching would be more of an issue: it'd be slick as hell if you could collapse a whole tree to a series of splines, but I smell recursion in the air, so I'm running away.....

But, a little bit of user interaction can go a long way, so as long as any given branch/tentacle got collapsed, it'd still be a worthy addition to the toolbox.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•