Notifications
Clear all

[Closed] Select all vertices in obect & weld

 em3

Hiya, I am trying to loop through all my geometry and weld the vertices. I thought it would be easy but it’s slow going so far. I have this…


(
Objs = for o in objects collect o

for o in Objs do
( 
	select o
subobjectLevel = 1
 actionMan.executeAction 0 "40021" --select all
meshOp.weldVertSet (what goes here?)
)	
)

Not sure what to put in the actual weld vertices part.

Thanks!

5 Replies

Use this function:

meshOp.weldVertsByThreshold o.mesh o.mesh.verts 0.0001

to weld all vertices in o object. 0.0001 is weld treshold…

EDIT:

You haven’t to collect the objects, you can just go throug objects set:
for o in objects do

for o in objects do
(
 	if( isKindOf o GeometryClass ) then -- weld only in geometry objects
 		meshOp.weldVertsByThreshold o.mesh o.mesh.verts 0.0001
 )
1 Reply
 em3
(@em3)
Joined: 11 months ago

Posts: 0

Thanks MiranDMC! yours works great and is more efficient than mine. I noticed you added isKindOf o GeometryClass which is amazing because that is what I have been looking for.

So what I want to say is
unparent everything
delete anything named “Block”
weld all vertices on all objects
add smooth modifier
delete all splines


for o in objects do 
(
for c in o.children do c.parent = undefined
)
(
if ( isKindOf o GeometryClass ) then
meshOp.weldVertsByThreshold o.mesh o.mesh.verts 0.1
modPanel.addModToSelection (smooth ()) ui:on	
else --???
delete o
)

Not too sure what the maxscript version of “else” is also I think I may have some (‘s in the wrong spots. Any guidance here is greatly appreciated.

Thanks man

 em3

found what I was looking for…


(
Objs = for o in objects collect o

for o in Objs do
	(
		select o
	convertToMesh o
	meshop.weldVertsByThreshold o o.verts 0.1   
	modPanel.addModToSelection (smooth ()) ui:on		
	) 
)

Thanks

for o in objects do
(
	 if( isKindOf o GeometryClass ) then -- weld only in geometry objects
	(
		if classof o.baseObject == Editable_Mesh then
		(
			meshOp.weldVertsByThreshold o.mesh o.mesh.verts 200
		)
		
		if classof o.BaseObject == Editable_Poly then
		(
			select o
			setCommandPanelTaskMode #modify;
			subObjectLevel = 1
			actionMan.executeAction 0 "40021"  -- Selection: Select All
			o.weldThreshold = 200
			o.EditablePoly.buttonOp  #WeldSelected
			subObjectLevel = 0
			setCommandPanelTaskMode #create ;
		)
	)
 )
 em3

This sort of does it…


for o in objects do
(
for c in o.children do c.parent = undefined
)
for o in objects  do
	(
if matchpattern o.name pattern:"*Block*" do
delete o	
	) 
	for o in objects  do
(
if ( isKindOf o GeometryClass ) then
	select o
	meshOp.weldVertsByThreshold o.mesh o.mesh.verts 0.1
	modPanel.addModToSelection (smooth ()) ui:on   

)
	for o in objects  do
(
if ( isKindOf o GeometryClass ) then  
	else
	delete o

)