# Maxscript help - weld vertices

**URL:** <https://forums.chaos.com/t/maxscript-help-weld-vertices/53531>\
**Category:** Off-topic\
**Created:** [April 23, 2015, 10:37am UTC](https://forums.chaos.com/t/maxscript-help-weld-vertices/53531 "2015-04-23T10:37:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterguthrie](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/peterguthrie/32/57456_2.png) [@peterguthrie](https://forums.chaos.com/u/peterguthrie)\
**Post date:** [April 23, 2015, 10:37am UTC](https://forums.chaos.com/t/maxscript-help-weld-vertices/53531/1 "2015-04-23T10:37:32Z")

</div>

Hello maxscript genuises!

looking for a script that will do the following nice and quickly:

- take 1 or several editable meshes  
- weld vertices (with a low threshold of 0.01 or 0.001 - doesnt need to have a UI)  
- auto smooth the geometry with a value of 30

thats it!

it can convert them to editable poly if thats easier/quicker, the main thing is that all scripts I have found take ages on heavy geometry

---

<div class="post-metadata">

**Author:** ![Donald2B](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/donald2b/32/3244_2.png) [@Donald2B](https://forums.chaos.com/u/Donald2B)\
**Post date:** [April 23, 2015, 12:11pm UTC](https://forums.chaos.com/t/maxscript-help-weld-vertices/53531/2 "2015-04-23T12:11:48Z")

</div>

The welding is what takes ages! Especially on heavy geometry. I deal with a lot of engineering data and some of the more complex pieces can take upwards of two (2) hours to weld with a threshold of 0.001. So I usually end of having about 4-5 copies of max running on my computer welding different pieces and then merging them all together.

I would be interested in a similar script as well. So I’m interested in how this turns out.

---

<div class="post-metadata">

**Author:** ![joconnell](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/joconnell/32/36063_2.png) [@joconnell](https://forums.chaos.com/u/joconnell)\
**Post date:** [April 23, 2015, 12:37pm UTC](https://forums.chaos.com/t/maxscript-help-weld-vertices/53531/3 "2015-04-23T12:37:43Z")

</div>

```auto

-- TYPE IN YOUR WELD VALUE HERE

theWeldThresh = 0.1

-- TYPE IN YOUR SMOOTH ANGLE HERE

theSmoothAngle = 30

theMeshes = selection as array

for i = 1 to theMeshes.count do
(

	theWeldMod = Welder threshold:theWeldThresh weldMethod:0

	--theWeldMod.threshold = theWeldThresh
	--theWeldMod.weldMethod = 0

	addModifier theMeshes[i] theWeldMod

	theSmoothmod = smooth autosmooth:on threshold:theSmoothAngle

	addModifier theMeshes[i] theSmoothmod

)

```

That’ll do it, but you can also use the welder modifier - it’s for welding cloth that’s to be ripped in a cloth sim later but it’s the same command as weld in edit poly or mesh. Then the smooth modifier. You can select all your objects and just apply these two modifiers and get them as instances if one value will work for the lot!

---

<div class="post-metadata">

**Author:** ![peterguthrie](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/peterguthrie/32/57456_2.png) [@peterguthrie](https://forums.chaos.com/u/peterguthrie)\
**Post date:** [April 23, 2015, 2:38pm UTC](https://forums.chaos.com/t/maxscript-help-weld-vertices/53531/4 "2015-04-23T14:38:59Z")

</div>

thanks John, very useful!

for some reason, having ‘don’t weld sel edges’ unticked seems to work better (in that it doesnt make otherwise invisible edges visible) how would we add that in to the magical recipe?

and at the end, could it collapse to editable poly?

---

<div class="post-metadata">

**Author:** ![peterguthrie](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/peterguthrie/32/57456_2.png) [@peterguthrie](https://forums.chaos.com/u/peterguthrie)\
**Post date:** [April 23, 2015, 2:44pm UTC](https://forums.chaos.com/t/maxscript-help-weld-vertices/53531/5 "2015-04-23T14:44:27Z")

</div>

actually the bit about ‘don’t weld sel edges’ might not be accurate. \< EDIT: It is

Man, I wish 3dsmax didnt insist on only using 2% of the available processor power for things like this!!!

---

<div class="post-metadata">

**Author:** ![peterguthrie](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/peterguthrie/32/57456_2.png) [@peterguthrie](https://forums.chaos.com/u/peterguthrie)\
**Post date:** [April 23, 2015, 2:54pm UTC](https://forums.chaos.com/t/maxscript-help-weld-vertices/53531/6 "2015-04-23T14:54:08Z")

</div>

what I have done in the past, is convert an editable mesh to editable poly, and then weld vertices in the editable poly options, it seems to be MUCH faster.

Would converting to editable poly in the script speed things up?

---

<div class="post-metadata">

**Author:** ![Rens](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/rens/32/16004_2.png) [@Rens](https://forums.chaos.com/u/Rens)\
**Post date:** [April 23, 2015, 2:54pm UTC](https://forums.chaos.com/t/maxscript-help-weld-vertices/53531/7 "2015-04-23T14:54:43Z")

</div>

Yeah, maxscript operations aren’t multithreaded. ;/

What usually speeds up the calculation is to switch off undo and switch to the create panel, also disable viewport updates.

```auto

max create mode
with redraw off(
undo off (
--code here
)
)

```

---

<div class="post-metadata">

**Author:** ![joconnell](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/joconnell/32/36063_2.png) [@joconnell](https://forums.chaos.com/u/joconnell)\
**Post date:** [April 23, 2015, 4:17pm UTC](https://forums.chaos.com/t/maxscript-help-weld-vertices/53531/8 "2015-04-23T16:17:31Z")

</div>

```auto
-- TYPE IN YOUR WELD VALUE HERE

theWeldThresh = 5.0

-- TYPE IN YOUR SMOOTH ANGLE HERE

theSmoothAngle = 30

theMeshes = selection as array

max create mode

with redraw off
(
undo off 
(

for i = 1 to theMeshes.count do
(

	theWeldMod = Welder threshold:theWeldThresh weldMethod:0 dontWeldSelectedEdges:off

	--theWeldMod.threshold = theWeldThresh
	--theWeldMod.weldMethod = 0

	addModifier theMeshes[i] theWeldMod

	theSmoothmod = smooth autosmooth:on threshold:theSmoothAngle

	addModifier theMeshes[i] theSmoothmod

	convertTo theMeshes[i] Editable_Poly

)
)
)

```

Those bits and Rens’ speed bits added.

---

<div class="post-metadata">

**Author:** ![Dave\_Wortley](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@Dave\_Wortley](https://forums.chaos.com/u/Dave_Wortley)\
**Post date:** [April 23, 2015, 5:49pm UTC](https://forums.chaos.com/t/maxscript-help-weld-vertices/53531/9 "2015-04-23T17:49:06Z")

</div>

Good geekery John!

---

<div class="post-metadata">

**Author:** ![Donald2B](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/donald2b/32/3244_2.png) [@Donald2B](https://forums.chaos.com/u/Donald2B)\
**Post date:** [April 23, 2015, 6:33pm UTC](https://forums.chaos.com/t/maxscript-help-weld-vertices/53531/10 "2015-04-23T18:33:17Z")

</div>

What’s the main advantage to using the welder modifier or the Weld Vertex modifier in this situation?

Just curious.
