ScriptSpot

Forum topic · General Scripting

Weld and Smooth

By eyepiz · 2013-10-28

Description

Hi All,

I found this script for Weld and Smooth and for some reason it does not work with 3DS max 2014. I get an error "--Unable to covert:"" to type: controller"

If anyone can take a look at it and get it to work properly it would be greatly appreciated.

Thanks!

--Weld and Smooth--- Nicholas O'Leary www.nicholasoleary.com
macroScript WeldAndSmooth category:"Nood" tooltip:"weldAndSmooth" icon:#("standard", 1)
(
rollout WeldAndSmooth "WeldAndSmooth" width:225 height:194
(

spinner faceIDCount_spn "Max face count included" pos:[19,16] width:196 height:16 enabled:true range:[1,1e+007,100000] type:#integer scale:0.1 controller:""
spinner weldDistance_spn "weld distance" pos:[18,43] width:196 height:16 enabled:true range:[1,1e+006,0.01] type:#float scale:0.001 controller:""
spinner smoothingAngle_spn "smoothing angle" pos:[18,70] width:196 height:16 enabled:true range:[0,360,20] type:#float scale:0.1 controller:""
button evaluate_btn "evaluate" pos:[126,162] width:90 height:21

on evaluate_btn pressed do
(
objorig = $ as array
for i = 1 to (poo.count) do

(
vert_array =#()
poo = convertToPoly(objorig[i])
poo.autoSmoothThreshold = faceIDCount_spn.value smoothingAngle_spn.value
vertCount = polyop.getNumVerts poo
for j= 1 to (vertCount) do
(
append vert_array j
)
polyop.weldVertsByThreshold poo vert_array

polyop.setFaceSelection poo #all
poo.EditablePoly.autosmooth ()
print i
)
--catch()
)
)
createDialog WeldAndSmooth 225 85
)

Comments (11)

Help!

eyepiz · 2014-08-26

Is there any way to get this script not to collapse to edit poly? I would help for scenes with lots of instances.

I appreciate any help!

Thanks,

barigazy · 2014-08-26

I upgraded Kostadin code. This works only on first instance in the current selection

try(destroydialog ::WeldAndSmooth) catch()
rollout WeldAndSmooth "WeldAndSmooth"
(
local weld = polyop.weldVertsByThreshold, selFace = polyop.setFaceSelection
fn filterPoly node = isKindOf node Editable_Poly
fn collectUniqueNodes objs = if objs.count != 0 do
(
local getNodeByHandle = maxOps.getNodeByHandle, getObjIns = InstanceMgr.GetInstances
local uniqNodes = #(), allINodes = #()
for o in objs do append allINodes o.inode.handle
while allINodes.count != 0 do
(
obj = (getNodeByHandle allINodes[allINodes.count])
getObjIns obj &firstOnly ; append uniqNodes firstOnly[firstOnly.count]
for o in firstOnly where (idx = findItem allINodes o.inode.handle) != 0 do deleteItem allINodes idx
)
uniqNodes
)
spinner spn_weldThreshold "Weld threshold:" range:[0,1e9,0.01] type:#float scale:0.001
spinner spn_smoothingAngle "Smoothing angle:" range:[0,360,20] type:#float scale:0.1
button evaluate_btn "Evaluate" width:200 height:30

on evaluate_btn pressed do if selection.count != 0 do
(
if (array = collectUniqueNodes (getCurrentSelection())).count != 0 do
(
for node in array where filterPoly node do
(
number = node.weldThreshold
node.autoSmoothThreshold = spn_smoothingAngle.value
node.weldThreshold = spn_weldThreshold.value
weld node #{1..(node.numverts)}
oPoly.weldThreshold = number
selFace node #all
node.EditablePoly.autoSmooth()
)
free array ; gc light:on
)
)
)
createDialog WeldAndSmooth 225 80

eyepiz · 2014-09-11

Thanks barigazy,

I'm getting "--Unknown property:"weldthreshold" in underfined"

eyepiz · 2013-10-31

Thanks guys you rock!

miauu · 2013-10-28

This is not the only error in the script. I have made new version.



macroscript miauuWeldAndSmooth
category:"miauu"
tooltip:"Weld And Smooth"
buttonText:"Weld And Smooth"
(
	rollout WeldAndSmooth "WeldAndSmooth"
	(
		spinner spn_weldThreshold "Weld threshold:" range:[1,1e+006,0.01] type:#float scale:0.001
		spinner spn_smoothingAngle "Smoothing angle:" range:[0,360,20] type:#float scale:0.1
		button evaluate_btn "Evaluate" width:200 height:30

		on evaluate_btn pressed do
		(
			selObjsArr = selection as array
			for o in selObjsArr do
			(
				oPoly = convertToPoly o
				oPoly.autoSmoothThreshold = spn_smoothingAngle.value
				curWeldThreshold = oPoly.weldThreshold
				oPoly.weldThreshold = spn_weldThreshold.value
				polyop.weldVertsByThreshold oPoly #{1..(oPoly.numverts)}
				oPoly.weldThreshold = curWeldThreshold
				polyop.setFaceSelection oPoly #all
				oPoly.EditablePoly.autoSmooth()
			)
		)
	)
	createDialog WeldAndSmooth 225 80
)

eyepiz · 2013-10-31

Hi Miauu,

Thanks for the script!... The Only thing I notice is that the Weld threshold defaults to 1.0 in the dialog box and will not go below 1.0 to like 0.001 any idea why this is happening?

Thanks again.

Eric

barigazy · 2013-10-31

Just correct this line

spinner spn_weldThreshold "Weld threshold:" range:[.001,1e+006,.01] type:#float scale:.001

eyepiz · 2014-04-21

Is there any way to get this script not to collapse to edit poly? I would help for scenes with lots of instances.

I appreciate any help!

Thanks,

.

miauu · 2013-10-31

It happens because I did'n notice that. Fixed.


macroscript miauuWeldAndSmooth
category:"miauu"
tooltip:"Weld And Smooth"
buttonText:"Weld And Smooth"
(
	rollout WeldAndSmooth "WeldAndSmooth"
	(
		spinner spn_weldThreshold "Weld threshold:" range:[0,1e9,0.01] type:#float scale:0.001
		spinner spn_smoothingAngle "Smoothing angle:" range:[0,360,20] type:#float scale:0.1
		button evaluate_btn "Evaluate" width:200 height:30
 
		on evaluate_btn pressed do
		(
			selObjsArr = selection as array
			for o in selObjsArr do
			(
				oPoly = convertToPoly o
				oPoly.autoSmoothThreshold = spn_smoothingAngle.value
				curWeldThreshold = oPoly.weldThreshold
				oPoly.weldThreshold = spn_weldThreshold.value
				polyop.weldVertsByThreshold oPoly #{1..(oPoly.numverts)}
				oPoly.weldThreshold = curWeldThreshold
				polyop.setFaceSelection oPoly #all
				oPoly.EditablePoly.autoSmooth()
			)
		)
	)
	createDialog WeldAndSmooth 225 80
)

eyepiz · 2013-12-06

Hey miauu

anyway we could get this to not break instances when converting to polly?

I appreciate any help.

Thanks

Eric

eyepiz · 2013-12-12

Can anyone give me some incite on how to accomplishes this?

I would appreciate any help.

Thanks!