Where is the variable?

Hi guys,

I have seen many code snippets like:

ONX_Model model;

// Read from file
if (!model.Read(filePath)) {
std::cerr << "Failed to read file: " << filePath << std::endl;
return false;
}

// Find the Brep object in the model
for (int i = 0; i < model.m_object_table.Count(); ++i)

even chatgpt show me the same codes, but “m_object_table” is now not defined. How could I loop all the geometric entities now?

Thank you.

Regards
John

You can loop all model space entities using an iterator:

ONX_Model model; // this model has been read from file
ONX_ModelComponentIterator it(model, ON_ModelComponent::Type::ModelGeometry);
for (auto pComp = it.FirstComponent(); pComp; pComp = it.NextComponent())
{
    const ON_ModelGeometryComponent* pGeometryComponent = ON_ModelGeometryComponent::Cast(pComp);
    // TODO: use the model geometry component
}

thank you.

thank you