STDMETHODIMP [!output CLASS_NAME]::CreateObject (AcDbObjectId ownerId /*=AcDbObjectId::kNull*/, TCHAR *keyName /*=NULL*/) { try { Acad::ErrorStatus es ; AcDbObjectPointer<[!output ARX_CLASS_NAME]> obj ; if ( (es =obj.create ()) != Acad::eOk ) throw es ; [!if ACAD_ENTITY_INTERFACE] obj->setDatabaseDefaults (ownerId.database ()) ; [!endif] [!output ARX_CLASS_NAME] *pTmp =NULL ; obj.release (pTmp) ; SetObject ((AcDbObject *&)pTmp) ; } catch ( const Acad::ErrorStatus ) { return (Error (L"Failed to create [!output ARX_CLASS_NAME]", IID_[!output INTERFACE_NAME], E_FAIL)) ; } return (S_OK) ; }
STDMETHODIMP CComPolygon::CreateObject(AcDbObjectId ownerId, TCHAR *keyName) { try { Acad::ErrorStatus es; AcDbObjectPointer<AsdkPoly> pPoly; if((es = pPoly.create()) != Acad::eOk) throw es; pPoly->setDatabaseDefaults(ownerId.database()); AsdkPoly *pTmp = NULL; pPoly.release(pTmp); SetObject((AcDbObject*&)pTmp); } catch(const Acad::ErrorStatus) { return Error(L"Failed to create polygon",IID_IComPolygon,E_FAIL); } return S_OK; }
HRESULT CAsdkSquareWrapper::CreateObject(AcDbObjectId ownerId, TCHAR *keyName) { try { Acad::ErrorStatus es; AcDbObjectPointer<AsdkSquare> pSq; if((es = pSq.create()) != Acad::eOk) throw es; pSq->setDatabaseDefaults(ownerId.database()); AsdkSquare *pTmp = NULL; pSq.release(pTmp); SetObject((AcDbObject*&)pTmp); } catch(const Acad::ErrorStatus) { return Error(L"Failed to create square",IID_IAsdkSquareWrapper, E_FAIL); } return S_OK; }