TA的每日心情 | 开心 7 小时前 |
---|
签到天数: 20 天 [LV.4]偶尔看看III
管理员
- 积分
- 1393
|
-
-
-
-
- 添加扩展数据======================
- static void TESTaddxdatacmd(){
- ads采用name en;
- ads采用point pt;
-
-
- 选择要添加扩展数据的对象
- if(acedEntSel(采用T("\n选择要添加扩展数据的实体"),en,pt) != RTNORM){
- return;
- }
-
-
- AcDbObjectId entId;
- Acad::ErrorStatus es = acdbGetObjectId(entId,en);
-
-
- 扩展数据的内容
- struct resbuf* pRb;
-
-
- 注册应用程序名称
- acdbRegApp(采用T("XData"));
-
-
- CString strAppName(采用T("XData"));;
- CString str(采用T("hello"));
- 创建结果缓冲区链表
- pRb = acutBuildList(AcDb::kDxfRegAppName,strAppName,
- AcDb::kDxfXdAsciiString,str,
- AcDb::kDxfXdInteger32,2,
- AcDb::kDxfXdReal,3.14,
- AcDb::kDxfXdWorldXCoord,pt,
- RTNONE);
-
-
- 为选择的实体添加扩展数据
- AcDbEntity* pEnt;
- acdbOpenAcDbEntity(pEnt,entId,AcDb::kForWrite);
- struct resbuf* pTemp;
- pTemp = pEnt->xData(采用T("XData"));
-
-
- if(pTemp != NULL){如果已经包含扩展数据,不再重复添加
-
-
- acutRelRb(pTemp);
- acutPrintf(采用T("它已经包含了扩展数据"));
- }
- else{
-
- pEnt->setXData(pRb);
- acutPrintf(采用T("\n扩展数据已赋值"));
- }
-
-
- pEnt->close();
- acutRelRb(pRb);
- }
-
-
- //查看扩展数据==================
- static void TESTviewxdatacmd(){
-
- 提示用户选择要查看的扩展数据对象
- ads采用name en;
- ads采用point pt;
-
-
- if(acedEntSel(采用T("\n选择要查看的扩展数据实体"),en,pt) != RTNORM){
-
- return;
- }
-
-
- AcDbObjectId entId;
- Acad::ErrorStatus es = acdbGetObjectId(entId,en);
-
-
- 打开图形对象,查看是否包含扩展数据
- AcDbEntity* pEnt;
- acdbOpenAcDbEntity(pEnt,entId,AcDb::kForRead);
- struct resbuf* pRb;
- pRb = pEnt->xData(采用T("XData"));
- pEnt->close();
-
-
- if(pRb != NULL){
-
- 在命令行显示所有的扩展数据
- struct resbuf* pTemp;
- pTemp = pRb;
-
-
- 首先要跳过应用程序名称
-
-
- pTemp = pTemp->rbnext;
- acutPrintf(采用T("\n字符串类型的扩展数据是:%s"),pTemp->resval.rstring);
-
-
- pTemp = pTemp->rbnext;
- acutPrintf(采用T("\n整数类型的扩展数据是:%d"),pTemp->resval.rint);
-
-
- pTemp = pTemp->rbnext;
- acutPrintf(采用T("\n实数类型的扩展数据是:%.2f"),pTemp->resval.rreal);
-
-
- pTemp = pTemp->rbnext;
- acutPrintf(采用T("\n点坐标类型的扩展数据是:%.2f,%.2f,%.2f"),pTemp->resval.rpoint[X],pTemp->resval.rpoint[Y],pTemp->resval.rpoint[Z]);
-
-
- acutRelRb(pRb);
- }
- else{
- acutPrintf(采用T("\n该实体不包含任何的扩展数据"));
- }
-
-
- }
-
-
-
-
- //添加扩展字典======================
- static void TESTaddrcdcmd(){
- ads采用name en;
- ads采用point pt;
-
-
- if(acedEntSel(采用T("\n选择要添加扩展记录的实体"),en,pt) != RTNORM){
-
- return;
- }
-
-
- AcDbObjectId entId;要添加扩展记录实体ID
- Acad::ErrorStatus es = acdbGetObjectId(entId,en);
-
-
- AcDbXrecord* pXrec = new AcDbXrecord;//= new AcDbxRecord;
- AcDbObject* pObj;
- AcDbObjectId dictObjId,xRecObjId;
- AcDbDictionary* pDict;
-
-
- 要在扩展记录中保存的字符串
- struct resbuf* pRb;
-
-
- /向实体中添加扩展字典
-
-
- acdbOpenObject(pObj,entId,AcDb::kForWrite);
- pObj->createExtensionDictionary();
- dictObjId = pObj->extensionDictionary();
- pObj->close();
-
-
- 向扩展字典中添加一条记录
- acdbOpenObject(pDict,dictObjId,AcDb::kForWrite);
- pDict->setAt(采用T("XRecord"),pXrec,xRecObjId);
- pDict->close();
-
-
- 设置扩展记录的内容
- pRb = acutBuildList(AcDb::kDxfText,采用T("\n直线"),
- AcDb::kDxfInt32,12,
- AcDb::kDxfReal,3.14,
- AcDb::kDxfXCoord,pt,
- RTNONE);
- pXrec->setFromRbChain(*pRb);
- pXrec->close();
-
-
- acutRelRb(pRb);
-
-
- }
-
-
- //查看扩展字典==============
- static void TESTviewrcdcmd(){
- 提示用户选择要查看扩展记录的图形对象
- ads采用name en;
- ads采用point pt;
-
-
- if(acedEntSel(采用T("\n选择要查看扩展记录的实体"),en,pt) != RTNORM)
- return;
-
-
- AcDbObjectId entId;
- Acad::ErrorStatus es = acdbGetObjectId(entId,en);
-
-
- 打开图形对象,获得实体扩展字典的OBJID
- AcDbEntity* pEnt;
- acdbOpenAcDbEntity(pEnt,entId,AcDb::kForRead);
- AcDbObjectId dictObjId = pEnt->extensionDictionary();
- pEnt->close();
-
-
- 查看实体是否包含扩展字典
- if(dictObjId == AcDbObjectId::kNull){
- acutPrintf(采用T("\n所选择的实体不包含扩展字典"));
- return;
- }
-
-
- 打开扩展字典,获得与关键字'XRECORD'关联的扩展记录
-
-
- AcDbDictionary* pDict;
- AcDbXrecord* pXrec;
- acdbOpenObject(pDict,dictObjId,AcDb::kForRead);
- pDict->getAt(采用T("XRecord"),(AcDbObject* &)pXrec,AcDb::kForRead);
- pDict->close();
-
-
- 获得扩展记录的数据链表并关闭扩展数据对象
- struct resbuf* pRb;
- pXrec->rbChain(&pRb);
- pXrec->close();
-
-
- if(pRb != NULL){
- 在命令行显示所有的扩展数据
- struct resbuf* pTemp;
- pTemp = pRb;
-
-
- acutPrintf(采用T("\n字符串类型的扩展数据是:%s"),pTemp->resval.rstring);
-
-
- pTemp = pTemp->rbnext;
- acutPrintf(采用T("\n整数类型的扩展数据是:%d"),pTemp->resval.rint);
-
-
- pTemp = pTemp->rbnext;
- acutPrintf(采用T("\n实数类型的扩展数据是:%.2f"),pTemp->resval.rreal);
-
-
- pTemp = pTemp->rbnext;
- acutPrintf(采用T("\n点坐标类型的扩展数据是:%.2f,%.2f,%.2f"),pTemp->resval.rpoint[X],pTemp->resval.rpoint[Y],pTemp->resval.rpoint[Z]);
-
-
- acutRelRb(pRb);
-
-
- }
- else{
- acutPrintf(采用T("\n没有找到它的扩展数据"));
- }
-
-
-
-
-
-
- }
复制代码 |
|