View Full Version : Select by Smoothing Group???
06-20-2006, 08:45 PM
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.
06-21-2006, 12:57 PM
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
-- 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.
06-21-2006, 06:14 PM
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.
06-22-2006, 07:11 AM
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.
06-22-2006, 07:38 AM
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
Where Num is 2^(smoothgroup-1)
06-22-2006, 07:38 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.