Get all Objects in C++?

I’m trying to create a plugin in c++ for rhino, and part of my goal is to find out if any objects intersect the selected, and if so, which ones. I’m rather new to coding in general, but so far have created an array of ID’s of the selected objects, if they are not hidden or locked, but am stuck on getting all objects, which I figure has to be possible since there is the _selAll command in Rhino, any advice for how to do this?

Hi @ogne941,

To “get” objects without picking, use a CRhinoObjectIterator object.

For example, this block of code will find “all” objects, including locked and hidden objects.

CRhinoCommand::result CCommandTest::RunCommand(const CRhinoCommandContext& context)
{
  unsigned int rhino_doc_sn = context.m_doc.RuntimeSerialNumber();
  CRhinoObjectIterator it(
    rhino_doc_sn, 
    CRhinoObjectIterator::undeleted_objects, 
    CRhinoObjectIterator::active_and_reference_objects
  );

  CRhinoObject* rhino_obj = nullptr;
  for (rhino_obj = it.First(); nullptr != rhino_obj; rhino_obj = it.Next())
  {
    // TODO...
  }

  context.m_doc.Redraw();

  return CRhinoCommand::success;
}

– Dale

Thank you for the quick response!