本文整理汇总了C++中AcDbDictionary类的典型用法代码示例。如果您正苦于以下问题:C++ AcDbDictionary类的具体用法?C++ AcDbDictionary怎么用?C++ AcDbDictionary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AcDbDictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeEntryFromDict
void
removeEntryFromDict(const char* strDictKey, AcDbDictionary* pParent,
const char* strEmpKey)
{
AcDbObjectId idO;
//see if our dictionary is there
ARXOK(pParent->getAt(strDictKey,idO));
//get it for write
AcDbObject* pO;
ARXOK(actrTransactionManager->getObject(pO,idO,AcDb::kForWrite));
//check if someone has else has created an entry with our name
//that is not a dictionary. This should never happen as long as
//I use the registered developer ID.
AcDbDictionary* pEmployeeDict;
if ((pEmployeeDict=AcDbDictionary::cast(pO))==NULL)
throw Acad::eNotThatKindOfClass;
//check if a record with this key isthere
ARXOK(pEmployeeDict->getAt(strEmpKey,idO));
//get it for write
ARXOK(actrTransactionManager->getObject(pO,idO,AcDb::kForWrite));
//and erase it
ARXOK(pO->erase());
//erase dictionary if it has no more entries
if (pParent->numEntries()==0)
ARXOK(pParent->erase());
}
示例2: AddLineType
static void AddLineType(CString lineTypeName)
{
// 加载线型(两种方法)
Acad::ErrorStatus es;
//es = acdbHostApplicationServices()->workingDatabase()->loadLineTypeFile(_T("CENTER"), _T("acadiso.lin"));
es = acdbLoadLineTypeFile(lineTypeName, _T("acadiso.lin"),acdbHostApplicationServices()->workingDatabase());
// 创建新的AcDbMlineStyle对象
AcDbMlineStyle *pMlStyle = new AcDbMlineStyle;
pMlStyle->initMlineStyle();
pMlStyle->setName(_T("NewStyle"));
int index; // 多线样式中的元素索引
//AcCmColor color; // 颜色
AcDbObjectId linetypeId; // 线型的ID
// 添加第一个元素(红色的中心线)
//color.setColorIndex(1); // 红色
GetLinetypeId(lineTypeName, linetypeId);
//pMlStyle->addElement(index, 0, color, linetypeId);
//// 添加第二个元素(蓝色的虚线)
//color.setColorIndex(5); // 蓝色
//GetLinetypeId("HIDDEN", linetypeId);
//pMlStyle->addElement(index, 0.5, color, linetypeId);
//// 添加第三个元素(蓝色的虚线)
//pMlStyle->addElement(index, -0.5, color, linetypeId);
//// 将多线样式添加到多线样式字典中
AcDbDictionary *pDict;
acdbHostApplicationServices()->workingDatabase()->getMLStyleDictionary(pDict, AcDb::kForWrite);
AcDbObjectId mlStyleId;
es = pDict->setAt(_T("NewStyle"), pMlStyle, mlStyleId);
pDict->close();
pMlStyle->close();
}
示例3: listXrecord
// The listxrecord() functions gets the xrecord associated with the
// key "ASDK_XREC1" and lists out its contents by passing the resbuf
// list to the function printList().
//
void
listXrecord()
{
AcDbObject *pObj;
AcDbXrecord *pXrec;
AcDbObjectId dictObjId;
AcDbDictionary *pDict;
pObj = selectObject(AcDb::kForRead);
if (pObj == NULL) {
return;
}
// Get the object ID of the object's extension dictionary.
//
dictObjId = pObj->extensionDictionary();
pObj->close();
// Open the extension dictionary and get the xrecord
// associated with the key ASDK_XREC1.
//
acdbOpenObject(pDict, dictObjId, AcDb::kForRead);
pDict->getAt("ASDK_XREC1", (AcDbObject*&)pXrec,
AcDb::kForRead);
pDict->close();
// Get the xrecord's data list and then close the xrecord.
//
struct resbuf *pRbList;
pXrec->rbChain(&pRbList);
pXrec->close();
printList(pRbList);
acutRelRb(pRbList);
}
示例4: FindDictKey
static bool FindDictKey( const AcDbObjectId& dictId, const CString& key )
{
AcDbDictionary* pDict = GetDictObject( dictId );
if( pDict == 0 ) return false;
bool ret = pDict->has( key );
pDict->close();
return ret;
}
示例5: CSCH081AddAttribute
//-------------------------------------------------------------------------------------------
//
// 功能: 将从AcDbObject派生数据库对象保存到实体的扩展词典中
//
// 作者:Qin H.X.
//
// 日期:200709
//
// 历史:
// 2007.10.08 修改 by Qin H.X.
//
//----------------------------------------------------------------------------------------------
// - CSCH081.AddAttribute command (do not rename)
static void CSCH081AddAttribute(void)
{
AcDbObjectId dictObjId,eId, attId;
AcDbDictionary* pDict;
//选择管道(多义线)
ads_name en;
ads_point pt;
if ( acedEntSel(_T("\n选择管道(多义线): "), en, pt)!= RTNORM)
{
acutPrintf(_T("\n选择失败,退出: "));
return ;
}
// 打开对象
acdbGetObjectId(eId, en);
AcDbEntity * pEnt;
acdbOpenObject(pEnt, eId, AcDb::kForWrite);
if(!pEnt->isKindOf (AcDbPolyline::desc ()))
{
acutPrintf(_T("\n选择的不是管道(多义线),退出: " ));
return ;
}
// 判断实体的扩展词典是否创建,如果没有则创建
dictObjId = pEnt->extensionDictionary();
if( dictObjId == AcDbObjectId::kNull )
{
pEnt->createExtensionDictionary();
}
// 获取实体的扩展词典
dictObjId = pEnt->extensionDictionary();
pEnt->close();
// 判断词典中的属性是否创建
CPipeAttribute* pAttribute;
acdbOpenObject(pDict, dictObjId, AcDb::kForWrite);
pDict->getAt (_T("属性"),attId);
if(attId!= AcDbObjectId::kNull )//如果已经创建则输出数据
{
acdbOpenObject(pAttribute, attId, AcDb::kForRead);
acutPrintf(_T("\n管径:%4.2f " ),pAttribute->m_dRadius);
acutPrintf(_T("\n壁厚:%4.2f " ),pAttribute->m_dThickness );
acutPrintf(_T("\n埋深:%4.2f " ),pAttribute->m_dDeep );
acutPrintf(_T("\n材质:%s " ),pAttribute->m_cMaterial );
}
else
{
//没有则创建属性
pAttribute = new CPipeAttribute();
pDict->setAt(_T("属性"), pAttribute, attId);
}
//关闭对象
pDict->close();
pAttribute->close();
}
示例6: RemoveDictKey
static void RemoveDictKey( const AcDbObjectId& dictId, const CString& key )
{
AcDbDictionary* pDict = GetDictObject( dictId );
if( pDict == 0 ) return;
AcDbObjectId objId;
pDict->remove( key, objId );
ArxEntityHelper::EraseObject2( objId, true ); // 删除对象
pDict->close();
}
示例7: IsDictExist
bool ArxDictTool::IsDictExist( const CString& dictName )
{
AcDbDictionary* pNamedobj;
acdbHostApplicationServices()->workingDatabase()->getNamedObjectsDictionary( pNamedobj, AcDb::kForRead );
bool ret = pNamedobj->has( dictName );
pNamedobj->close();
return ret;
}
示例8: createXrecord
// The createXrecord() functions creates an xrecord object,
// adds data to it, and then adds the xrecord to the extension
// dictionary of a user selected object.
//
// THE FOLLOWING CODE APPEARS IN THE SDK DOCUMENT.
//
void
createXrecord()
{
AcDbXrecord *pXrec = new AcDbXrecord;
AcDbObject *pObj;
AcDbObjectId dictObjId, xrecObjId;
AcDbDictionary* pDict;
pObj = selectObject(AcDb::kForWrite);
if (pObj == NULL) {
return;
}
// Try to create an extension dictionary for this
// object. If the extension dictionary already exists,
// this will be a no-op.
//
pObj->createExtensionDictionary();
// Get the object ID of the extension dictionary for the
// selected object.
//
dictObjId = pObj->extensionDictionary();
pObj->close();
// Open the extension dictionary and add the new
// xrecord to it.
//
acdbOpenObject(pDict, dictObjId, AcDb::kForWrite);
pDict->setAt("ASDK_XREC1", pXrec, xrecObjId);
pDict->close();
// Create a resbuf list to add to the xrecord.
//
struct resbuf* head;
ads_point testpt = {1.0, 2.0, 0.0};
head = acutBuildList(AcDb::kDxfText,
"This is a test Xrecord list",
AcDb::kDxfXCoord, testpt,
AcDb::kDxfReal, 3.14159,
AcDb::kDxfAngle, 3.14159,
AcDb::kDxfColor, 1,
AcDb::kDxfInt16, 180,
0);
// Add the data list to the xrecord. Notice that this
// member function takes a reference to a resbuf NOT a
// pointer to a resbuf, so you must dereference the
// pointer before sending it.
//
pXrec->setFromRbChain(*head);
pXrec->close();
acutRelRb(head);
}
示例9: searchOneDictionary
void
ArxDbgAppEditorReactor::collectAllDictRecords(AcDbDatabase* db, AcDbObjectIdArray& objIds)
{
AcDbDictionary* dict;
Acad::ErrorStatus es;
es = db->getNamedObjectsDictionary(dict, AcDb::kForRead);
if (es == Acad::eOk) {
searchOneDictionary(dict, objIds);
dict->close();
}
}
示例10: GetDictObject
bool ArxDictTool2::findEntry( const CString& key, AcDbObjectId& objId )
{
AcDbDictionary* pDict = GetDictObject( m_dictId );
if( pDict == 0 ) return false;
bool ret = ( Acad::eOk == pDict->getAt( key, objId ) );
//acutPrintf(_T("\nArxDitToll->Ret:%s"),ret?_T("Y"):_T("N"));
pDict->close();
return ret;
}
示例11: GetDict
AcDbObjectId ArxDictTool::GetDict( const CString& dictName )
{
AcDbDictionary* pNameObjDict;
if( Acad::eOk != acdbHostApplicationServices()->workingDatabase()->getNamedObjectsDictionary( pNameObjDict, AcDb::kForRead ) )
{
return AcDbObjectId::kNull;
}
AcDbObjectId dictId;
Acad::ErrorStatus es = pNameObjDict->getAt( dictName, dictId );
pNameObjDict->close();
return dictId;
}
示例12: addDictAndEntry
void
addDictAndEntry(const char* strDictKey, AcDbDictionary* pParent,
const char* strEmpKey, AcDbObject* pEmployee)
{
AcDbObjectId idO;
AcDbDictionary* pEmployeeDict;
//unerase the dictionary if it was erased
if (pParent->isErased())
ARXOK(pParent->erase(Adesk::kFalse));
//see if our dictionary is already there
if (pParent->getAt(strDictKey,idO)==Acad::eKeyNotFound){
//create it if not
if ((pEmployeeDict=new AcDbDictionary)==NULL)
throw Acad::eOutOfMemory;
Acad::ErrorStatus es;
pParent->upgradeOpen();
if ((es=pParent->setAt(strDictKey,pEmployeeDict,idO))!=Acad::eOk){
//make sure that we don't leak memory
//a smart pointer would come handy but let's not confuse
//everyone quite yet
delete pEmployeeDict;
throw es;
}
//this will ensure that the newly added object is properly
//committed to the db when the transaction ends
actrTransactionManager->addNewlyCreatedDBRObject(pEmployeeDict);
} else {
//get it for write if it is already there
AcDbObject* pO;
ARXOK(actrTransactionManager->getObject(pO,idO,AcDb::kForWrite));
//check if someone has else has created an entry with our name
//that is not a dictionary. This should never happen as long as
//I use the registered developer ID.
if ((pEmployeeDict=AcDbDictionary::cast(pO))==NULL)
throw Acad::eNotThatKindOfClass;
}
//check if a record with this key is already there
Acad::ErrorStatus es;
if ((es=pEmployeeDict->getAt(strEmpKey,idO))==Acad::eOk)
throw Acad::eAlreadyInDb;
if (es!=Acad::eKeyNotFound)
throw es;
ARXOK(pEmployeeDict->setAt(strEmpKey,pEmployee,idO));
//this will ensure that the newly added object is properly
//committed to the db when the transaction ends
actrTransactionManager->addNewlyCreatedDBRObject(pEmployee);
}
示例13: listTree
// The list tree function runs through all objects in the ASDK_DICT dictionary,
// follows their ownership trees, and lists out information
// on all objects in the tree.
//
void
listTree()
{
AcDbDictionary *pNamedobj;
AcDbDictionary *pDict;
acdbHostApplicationServices()->workingDatabase()
->getNamedObjectsDictionary(pNamedobj, AcDb::kForWrite);
// Get a pointer to the ASDK_DICT dictionary.
//
if (pNamedobj->getAt(_T("ASDK_DICT"), (AcDbObject*&) pDict,
AcDb::kForRead) == Acad::eKeyNotFound)
{
pNamedobj->close();
return ;
}
pNamedobj->close();
// Run through the entries and list their backpointers.
//
AcDbDictionaryIterator *pDictItr = pDict->newIterator();
for (; !pDictItr->done(); pDictItr->next()) {
printOut(pDictItr->objectId());
}
delete pDictItr;
pDict->close();
}
示例14: CreateSubDictionaryID
Acad::ErrorStatus CTwArxDictionary::CreateSubDictionaryID( IN const AcDbObjectId& IdRoot, IN const CString& strKey, OUT AcDbObjectId& IdSubDic, IN AcRxClass* pRxObjType /*= AcDbDictionary::desc() */ ) const
{
if( pRxObjType == NULL ) return Acad::eNullObjectPointer;
Acad::ErrorStatus es = Acad::eOk;
AcDbDictionary* pDicRoot = NULL;
AcDbDatabase* pWdb = acdbCurDwg();
if( IdRoot.isNull() )
es = pWdb->getNamedObjectsDictionary( pDicRoot, AcDb::kForRead );
else
es = acdbOpenObject( pDicRoot, IdRoot, AcDb::kForRead );
if( es != Acad::eOk ) return es;
if( pDicRoot->has(strKey) )
{
pDicRoot->getAt( strKey, IdSubDic );
pDicRoot->close();
return es;
}
pDicRoot->upgradeOpen();
AcDbObject* pObj = (AcDbObject*)pRxObjType->create();
es = pDicRoot->setAt( strKey, pObj, IdSubDic );
pObj->close();
pDicRoot->close();
return es;
}
示例15: setup
// Adds the reactor to the editor to monitor changes.
//
void
setup()
{
acedEditor->addReactor(gpEdReac);
acutPrintf("Added new command to Wblock.\n");
// Now, for this sample only, we need to create a
// new dictionary, add it to the named object
// dictionary using the key string specified by the
// constant pointer kpDictionary. Then we'll create
// a couple of empty xrecords and put them into the
// new dictionary. All of this provides the objects
// that our code will be cloning across.
//
AcDbDictionary *pNamedobj;
acdbHostApplicationServices()->workingDatabase()
->getNamedObjectsDictionary(pNamedobj, AcDb::kForRead);
AcDbDictionary *pDict;
// Search for the dictionary associated with the key
// kpDictionary. If it's not found, then create it,
// add it to the namedobjects dictionary, and then
// create and add a few xrecords to it.
//
// If it is found then do nothing because it's already
// been done sometime previously.
//
if (!pNamedobj->has(kpDictionary))
{
if (pNamedobj->upgradeOpen() == Acad::eOk) {
pDict = new AcDbDictionary;
AcDbObjectId DictId;
pNamedobj->setAt(kpDictionary, pDict, DictId);
pNamedobj->close();
AcDbXrecord *pObj1 = new AcDbXrecord(),
*pObj2 = new AcDbXrecord();
AcDbObjectId rId1, rId2;
pDict->setAt("OBJ1", pObj1, rId1);
pDict->setAt("OBJ2", pObj2, rId2);
pObj1->close();
pObj2->close();
pDict->close();
} else
pNamedobj->close();
}
}