![]() |
|
This example demonstrates how to obtain the entities contained in one of the so-called "container" classes in SketchUp.
A container in SketchUp is an object that contains other objects. In the SketchUp API, a container is an object that implements the ISkpEntityProvider interface. The documentation of this interface shows which classes support this interface.
HRESULT GetEntitesFromEntityProvider(IUnknown* pUnk, ISkpEntities** pEntities) { if(pEntities == NULL) { return E_POINTER; } *pEntities = NULL; if(pUnk == NULL) { return E_INVALIDARG; } HRESULT hr = S_OK; // Get the ISkpEntityProvider from the IUnknown provider that was passed in. CComPtr<ISkpEntityProvider> pProvider; hr = pUnk->QueryInterface(IID_ISkpEntityProvider, (void**)&pProvider); if(FAILED(hr)) { return hr; } return pProvider->get_Entities(pEntities); } // Get the entities from an ISkpComponentDefinition, which implements the ISkpEntityProvider interface. HRESULT GetEntitiesFromComponentDefinition(ISkpComponentDefinition* pDefn, ISkpEntities** pEntities) { CComPtr<IUnknown> pUnk; HRESULT hr = S_OK; hr = pDefn->QueryInterface(IID_IUnknown, (void**)&pUnk); if(FAILED(hr)) { return hr; } return GetEntitesFromEntityProvider(pUnk, pEntities); } // Get the entities from an ISkpSelectionSet, which implements the ISkpEntityProvider interface. HRESULT GetEntitiesFromSelectionSet(ISkpSelectionSet* pSelectionSet, ISkpEntities** pEntities) { CComPtr<IUnknown> pUnk; HRESULT hr = S_OK; hr = pSelectionSet->QueryInterface(IID_IUnknown, (void**)&pUnk); if(FAILED(hr)) { return hr; } return GetEntitesFromEntityProvider(pUnk, pEntities); }
©2010 Google - Google Home - About Google |