[Closed] Select by Smoothing Group???
Is there any simple way to programatically select faces/polygons of a mesh by Smoothing Group. Its quick and easy using the ‘Select by SG’ button under mesh edit, but I can’t seem to duplicate it with MaxScript.
Thanks
Hamster139
This should do the trick:
fn SelectBySmoothGroup theObject theSG =
(
-- Get the object's mesh
obj = theObject.mesh
-- Get the face count of the mesh
numFaces = getNumFaces obj
-- Cycle through all the faces, when a face has the same bit flag set in it's smoothing group
-- collect it and put it in faces
faces = for i = 1 to numFaces where (bit.get (getFaceSmoothGroup obj i) theSG) collect i
-- Select the faces
setFaceSelection obj faces
-- Update the mesh
update theObject
)
-- This will select all faces with smoothing group 1 set in the selected object.
SelectBySmoothGroup $ 1
I don’t know if the code could be made more optimal, it wouldn’t surprise me if it could.
Hope this helps.
Thanks for the code.
I tried the code, and it doesn’t work for me. There aren’t any errors, it just doesn’t select anything. I don’t know if it makes a difference, but I first select the object, then select the ‘mesh edit’ modifier, then I run the code.
Hamster139
This script will only work on an object that’s been collapsed to an editable mesh. There is unfortunately no script access to edit mesh other than creating it.
Thanks for the input, I found something that works well for my situation, by converting it to a polymesh (which can use the selectBySmoothGroup). I needed something quick and dirty, cuz my meshes were really complex, and I needed to select more than 1 SG at a time.
convertTo $ PolyMeshObject
max modify mode
subobjectLevel = 4
$.EditablePoly.selectBySmoothGroup Num
Where Num is 2^(smoothgroup-1)
hamster139