THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/07/2011 at 22:19, xxxxxxxx wrote:
This is from my InterPoser Pro Tool Draw method. The mouseX and mouseY are stored in GetCursorInfo() for the tool.
// Mouse outside of Editor view
if (mouseX < 0.0) return drawFlags;
// Add IPP objects under cursor to selection list
AutoAlloc<C4DObjectList> objList;
if (!objList) return drawFlags;
if (!SelectionListCreate(doc, NULL, bd, mouseX, mouseY, NULL, objList)) return drawFlags;
LONG cnt = objList->GetCount();
if (!cnt) return drawFlags;
// Set level of object to highlight
LONG i = 0L;
LONG a = 0L;
// - lets us go back to level=0 if the level is beyond valid selections
LONG seg = -1L;
BaseTag* ippTag = NULL;
BaseObject* obj = NULL;
BaseContainer* bc = NULL;
BaseContainer* fbc = NULL;
// Skip objects in list that aren't conformant
for (a = 0; a < cnt; ++a)
{
obj = objList->GetObject(a);
// Only check IPP objects
if (obj->IsInstanceOf(ID_IPPBASE))
{
if (!(bc = obj->GetDataInstance())) continue;
hilitedBP = obj;
obj = bc->GetObjectLink(IPP_ROOT, doc);
if (!obj) return drawFlags;
}
ippTag = obj->GetTag(ID_IPPFIGURETAG);
if (!ippTag)
{
ippTag = obj->GetTag(ID_IPPOBJECTTAG);
if (!ippTag) continue;
}
if (ippTag->IsInstanceOf(ID_IPPFIGURETAG) && skipConformers)
{
fbc = ippTag->GetDataInstance();
if (fbc && fbc->GetBool(IPPFIGURE_CONFORMED)) continue;
}
if (seg == -1L) seg = a;
if (i == level) break;
++i;
}
// - Invalid IPP object
if (!(ippTag && obj)) return drawFlags;
if (a == cnt)
{
if (seg != -1L)
{
level = 0L;
a = seg;
}
else return drawFlags;
}
Basically, I am getting a list of objects under the cursor using a C4DObjectList instance and making determinations about the validity afterwards (probably not as important but included for thoroughness). So, you could take the nearest object (using C4DObjectList::GetZ() to determine 'nearest') and then SetActiveObject() based on that criteria.