STDMETHODIMP [!output CLASS_NAME]::AddToDb (AcDbObjectId &objId, AcDbObjectId ownerId /*=AcDbObjectId::kNull*/, TCHAR *keyName /*=NULL*/) { try { AcAxDocLock docLock (ownerId) ; Acad::ErrorStatus es ; AcAxObjectRefPtr<[!output ARX_CLASS_NAME]> obj (&m_objRef, AcDb::kForRead) ; [!if ACAD_ENTITY_INTERFACE] //----- Entities can be owned by block table records only AcDbBlockTableRecordPointer pBlockTableRecord (ownerId, AcDb::kForWrite, true) ; if ( (es =pBlockTableRecord.openStatus ()) != Acad::eOk ) throw es ; if ( (es =pBlockTableRecord->appendAcDbEntity (objId, obj.object ())) != Acad::eOk ) throw es ; [!else] //----- Non-entities cannot be owned by block table record, but are //----- usually owned by dictionaries. If this is not your case, please //----- change the code below. AcDbDictionaryPointer pDictionary (ownerId, AcDb::kForWrite, true) ; if ( (es =pDictionary.openStatus ()) != Acad::eOk ) throw es ; if ( (es =pDictionary->setAt (keyName, obj.object (), objId)) != Acad::eOk ) throw es ; [!endif] } catch( const Acad::ErrorStatus ) { return (Error(L"Failed to add [!output ARX_CLASS_NAME] to database", IID_[!output INTERFACE_NAME], E_FAIL)) ; } return (SetObjectId (objId)) ; }
STDMETHODIMP CComPolygon::AddToDb(AcDbObjectId& objId, AcDbObjectId ownerId, TCHAR* keyName) { try { AXEntityDocLock(ownerId); Acad::ErrorStatus es; AcAxObjectRefPtr<AsdkPoly> pPoly(&m_objRef, AcDb::kForRead); AcDbBlockTableRecordPointer pBlockTableRecord(ownerId, AcDb::kForWrite); if((es = pBlockTableRecord.openStatus()) != Acad::eOk) throw es; if((es = pBlockTableRecord->appendAcDbEntity(objId, pPoly.object())) != Acad::eOk) throw es; } catch(const Acad::ErrorStatus) { //we can becaome more sophisticated return Error(L"Failed to add polygon to database",IID_IComPolygon,E_FAIL); } return SetObjectId(objId); }
SectionBar::SectionBar( Control& parent ) : Control( parent ), m_section( nullptr ) { SetObjectId( "IWSectionBar" ); SetFocusStyle( FocusStyle::NoFocus ); SetSizer( Global_Sizer ); Global_Sizer.AddSpacing( 1 ); Global_Sizer.Add( Title_Sizer ); Global_Sizer.AddSpacing( 1 ); Title_Sizer.AddSpacing( 4 ); Title_Sizer.Add( Title_Label ); Title_Sizer.AddStretch(); Title_Sizer.Add( Title_ToolButton ); Title_Sizer.AddSpacing( 4 ); Title_Label.SetText( String( 'M' ) ); Title_Label.SetTextAlignment( TextAlign::Left|TextAlign::VertCenter ); Title_Label.SetText( String() ); Title_ToolButton.SetIcon( Bitmap( ScaledResource( contract_icon ) ) ); Title_ToolButton.SetScaledFixedSize( 17, 17 ); Title_ToolButton.SetFocusStyle( FocusStyle::NoFocus ); Title_ToolButton.OnClick( (Button::click_event_handler)&SectionBar::ButtonClick, *this ); AdjustToContents(); SetFixedHeight(); OnMousePress( (Control::mouse_button_event_handler)&SectionBar::MousePress, *this ); OnShow( (Control::event_handler)&SectionBar::ControlShow, *this ); }
Extension::Extension(int self, const QString& simpleId, const QString& namespaze, const QList<int>& children, int extraData, ExtensionRegistry* registry, bool persist) : RegistryObject(registry, persist), simpleId(simpleId), namespaceIdentifier(namespaze) { for (int i = 0; i < EXTRA_SIZE; ++i) extraInformation << QString(); SetObjectId(self); SetRawChildren(children); SetExtraDataOffset(extraData); }
HRESULT CAsdkSquareWrapper::AddToDb(AcDbObjectId& objId, AcDbObjectId ownerId, TCHAR* keyName) { try { AcAxDocLock docLock(ownerId); Acad::ErrorStatus es; AcAxObjectRefPtr<AsdkSquare> pSq(&m_objRef, AcDb::kForRead); AcDbBlockTableRecordPointer pBlockTableRecord(ownerId, AcDb::kForWrite); if((es = pBlockTableRecord.openStatus()) != Acad::eOk) throw es; if((es = pBlockTableRecord->appendAcDbEntity(objId, pSq.object())) != Acad::eOk) throw es; } catch(const Acad::ErrorStatus) { //we can becaome more sophisticated return Error(L"Failed to add square to database", IID_IAsdkSquareWrapper ,E_FAIL); } return SetObjectId(objId); }