ScriptSpot

Forum topic · General Scripting

Select objects with no smoothing group

By ratatouille · 2019-01-06

Description

Hello,
i need to do select objects which has polygons of no smoothing group.
and im very noob in maxscript.

fn selectFacesWithNoSG theObject =
(
polyOp.setFaceSelection theObject (for f = 1 to polyop.getNumFaces theObject where polyop.getFaceSmoothGroup theObject f == 0 collect f)
)

I dont know why its not working..
thank you in advance.

Comments (7)

.

miauu · 2019-01-07

This works for me:


(
	obj = selection[1]
	facesBA = #{1..(polyop.GetNumFaces obj)}
	noSMGFacesArr = for f in facesBA where (polyop.getFaceSmoothGroup obj f) == 0 collect f
	if noSMGFacesArr.count != 0 do
		polyop.setFaceSelection obj noSMGFacesArr
	redrawViews()
)

.

jahman · 2019-01-07

he needs to select objects not faces ;)




NodesWithNoSGfaces = for obj in selection where canConvertTo obj Editable_mesh collect
(
	local found = false
	local tri = snapshotAsMesh obj
	
	for f=1 to tri.numfaces while not found where getFaceSmoothGroup tri f == 0 do
	(
		found = true
	)
	
	free tri
	
	if found then obj else dontCollect	
)

select NodesWithNoSGfaces

.

miauu · 2019-01-07

Yep. My bad. :)

.

ratatouille · 2019-01-09

@jahman
Thank you man! This works great!! like charm!!

And
@miauu
I have posted this thread expecting your replay actually.
and you make it!. you have done reading my mind becoz when i tried to find objects and i will surely look for culprit polygons with noSG. thaks.

Both script is important!!

.

miauu · 2019-01-09

Most important is that you have working tools.

I searched such feature

x_OL · 2020-02-23

@miauu:
I searched exactly such feature - to check if all polygons has smooth groups before export. Work good in 2020. Thanks :)

.

miauu · 2020-02-23

I am glad that the script is useful to you. :)