Working with the Selection List as a CRefArray (C++ API only)

- The Selection class provides access to the selected items in a convenient CRefArray via the Selection::GetArray function:

// C++ API
CRefArray sellist = app.GetSelection().GetArray();
LONG lSelCount = sellist.GetCount();
for (LONG i=0; i<lSelCount; i++) {
   CRef currItem = sellist[i];
   if ( currItem.IsValid() ) {
       if ( currItem.GetClassIDName() == L"X3DObject" ) {
          X3DObject x3dobj(currItem);
          app.LogMessage(L"item[" + CString(i) + L"]: " + x3dobj.GetName() );
       } else {
          app.LogMessage(L"item[" + CString(i) + L"]: " + currItem.GetClassIDName() );
          // For components this will return 'Object' which is the generic object type
       }
   } else {
       app.LogMessage(L"item[" + CString(i) + L"] is not valid." );
   }
}

 



Autodesk Softimage v7.5