This is useful for example in case you want to highlight an edge.
The component arrives as the first and only element of the Component Collection of the SubComponent property of a CollectionItem. Phew ,).... The C++ API doesn't provide access to either of those elements, so you'll have to go through the CComAPIHander again (similar to handling component selections)
So basically to get the component, you will have to do:
Code: Select all
CRef ref = in_ctxt.GetSnapComponent();
if(!ref.IsValid())
break;
CComAPIHandler cCollItem(ref);
CComAPIHandler cSubComp(cCollItem.GetProperty(L"SubComponent"));
CComAPIHandler cCompColl(cSubComp.GetProperty(L"ComponentCollection"));
if(LONG(cCompColl.GetProperty(L"Count")) != 1L)
break;
CValue rVal;
CValueArray rrParams;
rrParams.Add(0L);
CStatus bOk = cCompColl.Invoke(L"Item", CComAPIHandler::PropertyGet, rVal, rrParams);
CRef edgeRef(rVal);
Edge theEdge(edgeRef);
Code: Select all
Edge theEdge(in_ctxt.GetSnapComponent());
would have been easier.... but it works ;)
Note that snap works on the unsubdivided mesh of a subd surface, and pick works on the subdivided mesh (uses a hidden pick bitmap)
Hope this helps somebody get started with custom tool programming.