Objects affected by TextureMappingTableEvent

Hi all,

I am trying to work with TextureMappingTableEvent to trigger some operations on the objects affected by this event. In the MaterialTableEvent I can get these objects in this way:

const CRhinoMaterial& material = material_table[material_index];
ON_SimpleArray<CRhinoObject*> objects;
int object_count = ::RhinoApp().ActiveDoc()->LookupObject(material, objects);

I cannot find something similar for the texture mapping. Is there another way to get the objects using a given texture mapping?


Hi @gennaro,

I haven’t tested this. But something like this should work:

int RhinoLookupObject(
  CRhinoDoc& doc,
  const CRhinoTextureMapping& texture_mapping,
  ON_SimpleArray<CRhinoObject*>& obj_list
  int count = 0;
  const ON_UUID texture_mapping_id = texture_mapping.Id();
  CRhinoObjectIterator it(doc, CRhinoObjectIterator::undeleted_objects);
  CRhinoObject* obj = nullptr;
  for (obj = it.First(); nullptr != obj; obj = it.Next()) 
    const ON_ObjectRenderingAttributes& rendering_attributes = obj->Attributes().m_rendering_attributes;
    bool found = false;
    for (int i = 0; false == found && i < rendering_attributes.m_mappings.Count(); i++)
      const ON_MappingRef& mapping_ref = rendering_attributes.m_mappings[i];
      for (int j = 0; j < mapping_ref.m_mapping_channels.Count(); j++)
        const ON_MappingChannel& mapping_channel = mapping_ref.m_mapping_channels[j];
        if (mapping_channel.m_mapping_id == texture_mapping_id)
          if (0 == obj_list.Count())
          found = true;
  return count;

– Dale