- UID
- 319
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-11
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
![](source/plugin/imc_colorcode/images/loading.gif)
- #include <rxregsvc.h>
- #include <aced.h>
- #include <dbidmap.h>
- #include <lngtrans.h>
- #include <dbltrans.h>
- #include <dbmain.h>
- #include <dbsymtb.h>
- #include <dbents.h>
- #include <dbapserv.h>
- #include <adslib.h>
- void
- refEdit()
- {
- AcDbObjectId transId;
- AcDbDatabase* pDb;
- char *fname;
- struct resbuf *rb;
- rb = acutNewRb(RTSTR);
- int stat = acedGetFileD("Pick a drawing", NULL, "dwg", 0, rb);
-
- if ((stat != RTNORM) || (rb == NULL))
- {
- acutPrintf("\nYou must pick a drawing file.");
- return;
- }
- fname = (char*)acad_malloc(strlen(rb->resval.rstring) + 1);
- strcpy(fname, rb->resval.rstring);
- acutRelRb(rb);
-
- pDb = new AcDbDatabase(Adesk::kFalse);
- if (pDb->readDwgFile(fname) != Acad::eOk)
- {
- acutPrintf("\nSorry, that draing is probably already open.");
- return;
- }
- AcDbBlockTable *pBlockTable;
- pDb->getSymbolTable(pBlockTable, AcDb::kForRead);
- AcDbBlockTableRecord *pOtherMsBtr;
- pBlockTable->getAt(ACDB_MODEL_SPACE, pOtherMsBtr, AcDb::kForRead);
- pBlockTable->close();
- AcDbBlockTableRecordIterator *pIter;
- pOtherMsBtr->newIterator(pIter);
- AcDbObjectIdArray objIdArray;
- for (pIter->start(); !pIter->done(); pIter->step()) {
- AcDbEntity *pEntity;
- pIter->getEntity(pEntity, AcDb::kForRead);
- if (pEntity->isKindOf(AcDbCircle::desc())) {
- objIdArray.append(pEntity->objectId());
- }
- pEntity->close();
- }
- delete pIter;
- pOtherMsBtr->close();
- if (objIdArray.isEmpty()) {
- acad_free(fname);
- acutPrintf("\nYou must pick a drawing file that contains circles.");
- return;
- }
- AcDbBlockTable *pThisBlockTable;
- acdbHostApplicationServices()->workingDatabase()
- ->getSymbolTable(pThisBlockTable, AcDb::kForRead);
- AcDbBlockTableRecord *pThisMsBtr;
- pThisBlockTable->getAt(ACDB_MODEL_SPACE, pThisMsBtr, AcDb::kForWrite);
- pThisBlockTable->close();
-
- AcDbObjectId id = pThisMsBtr->objectId();
- pThisMsBtr->close();
- AcDbIdMapping errorMap;
- acapLongTransactionManagerPtr()->checkOut(transId, objIdArray, id, errorMap);
- int colorIndex;
- double radius;
- acedGetInt("\nEnter color number to circles center line: ", &colorIndex);
- acedGetReal("\nEnter circle radius: ",&radius);
- if (radius<=0)
- {
- acutPrintf("\nError:Radius can't less than 0!");
- return;
- }
- AcDbObject* pObj;
- if (acdbOpenObject(pObj, transId, AcDb::kForRead) == Acad::eOk)
- {
- AcDbLongTransaction* pLongTrans = AcDbLongTransaction::cast(pObj);
- if (pLongTrans != NULL)
- {
- AcDbLongTransWorkSetIterator* pWorkSetIter;
- pLongTrans->newWorkSetIterator(pWorkSetIter);
- for (pWorkSetIter->start(); !pWorkSetIter->done(); pWorkSetIter->step())
- {
- AcDbEntity *pEntity;
- acdbOpenAcDbEntity(pEntity, pWorkSetIter->objectId(), AcDb::kForWrite);
- pEntity->setColorIndex(colorIndex);
- ((AcDbCircle*)pEntity)->setRadius(radius);
- pEntity->close();
- }
- delete pWorkSetIter;
- }
- pObj->close();
- }
- char str[132];
- acedGetString(0, "\nSee the new colors and radius. Press return to back", str);
- acapLongTransactionManagerPtr()->checkIn(transId, errorMap);
- pDb->saveAs(fname);
- delete pDb;
- pDb = NULL;
- acad_free(fname);
- }
- void
- initApp()
- {
- acedRegCmds->addCommand("EXAM04A",
- "LONGTRANS",
- "LONGTRANS",
- ACRX_CMD_MODAL,
- refEdit);
- }
- void unloadApp()
- {
- acedRegCmds->removeGroup("EXAM04A");
- }
- extern "C" AcRx::AppRetCode
- acrxEntryPoint(AcRx::AppMsgCode msg, void* appId)
- {
- switch (msg) {
- case AcRx::kInitAppMsg:
- acrxDynamicLinker->unlockApplication(appId);
- acrxDynamicLinker->registerAppMDIAware(appId);
- initApp();
- break;
- case AcRx::kUnloadAppMsg:
- unloadApp();
- break;
- case AcRx::kLoadDwgMsg:
- break;
- case AcRx::kUnloadDwgMsg:
- break;
- case AcRx::kInvkSubrMsg:
- break;
- default:
- ;
- }
- return AcRx::kRetOK;
- }
|
|