How do I Select a Face of an Editable Mesh by its Index?

A user asked:

Is there a way to select a face in an editable mesh when you only know its index?

Answer:

When doing it just once, you can quickly type in the Listener something like:

setFaceSelection $ {10}

This selects the face with index 10 assuming that a single object is selected and it is an Editable_Mesh.

If you are doing this very often, the following macroScript provides a UI with a spinner to select the face index and some error handling:

SCRIPT

   macroScript FaceByIndex category:"MXS Help"
   (
   global SelectFaceRoll
   try (destroyDialog SelectFaceRoll) catch()

   rollout SelectFaceRoll "Select Face"
   (
     spinner face_index "Face Index" type:#integer range:[1,100000000,1]
     on face_index changed val do
     (
       if isValidNode selection[1] and classof selection[1].baseobject == Editable_Mesh do
       (
         if val <= selection[1].numfaces then
           setFaceSelection selection[1] #{val}
         else   
           setFaceSelection selection[1] #{}
       )
     )
   )
   max modify mode
   try (subObjectLevel = 3) catch()
   createDialog SelectFaceRoll 150 30
   )--end macro