TA的每日心情 | 开心 昨天 06:36 |
---|
签到天数: 15 天 [LV.4]偶尔看看III
管理员
- 积分
- 1308
|
- static void ChangeStyle() {
- AcDbObjectId styleId;
- // Create a text style
- {
- AcDbObjectPointer<AcDbTextStyleTable>
- pTextStyleTable(acdbCurDwg()->textStyleTableId(), AcDb::kForWrite);
- AcDbObjectPointer<AcDbTextStyleTableRecord> pStyle;
- pStyle.create();
- pStyle->setName(L"MyStyle");
- pStyle->setFileName(L"romans.shx");
- if (pTextStyleTable->add(styleId, pStyle.object()) != Acad::eOk)
- {
- pTextStyleTable->getAt(L"MyStyle", styleId);
- }
- }
- acedAlert(L"created text style");
- AcDbObjectId idtext;
- // Create some text
- {
- AcDbObjectPointer<AcDbText> pText;
- pText.create();
- pText->setDatabaseDefaults();
- pText->setTextStyle(styleId);
- pText->setTextString(L"Some text");
- pText->setHeight(10);
- AcDbObjectPointer<AcDbBlockTableRecord>
- pSpace(acdbCurDwg()->currentSpaceId(), AcDb::kForWrite);
- pSpace->appendAcDbEntity(idtext, pText);
- }
- acTransactionManagerPtr()->flushGraphics();
- acedUpdateDisplay();
- acedAlert(L"created text");
- {
- // Change the font file for the text style
- AcDbObjectPointer<AcDbTextStyleTableRecord>
- pStyle(styleId, AcDb::kForWrite);
- pStyle->setFileName(L"romand.shx");
- }
- {
- AcDbObjectPointer<AcDbBlockTableRecord>
- pSpace(acdbCurDwg()->currentSpaceId(), AcDb::kForRead);
- AcDbBlockTableRecordIterator *pIter = NULL;
- pSpace->newIterator(pIter);
- AcDbObjectId id;
- for (; !pIter->done(); pIter->step())
- {
- id.setNull();
- pIter->getEntityId(id);
- if (id.objectClass()->isDerivedFrom(AcDbText::desc()) ||
- id.objectClass()->isDerivedFrom(AcDbMText::desc()) ||
- id.objectClass()->isDerivedFrom(AcDbDimension::desc()) ||
- id.objectClass()->isDerivedFrom(AcDbBlockReference::desc()))
- {
- AcDbEntityPointer pEnt(id, AcDb::kForWrite);
- if (pEnt.openStatus() == Acad::eOk)
- pEnt->recordGraphicsModified();
- }
- }
- delete pIter;
- }
- acTransactionManagerPtr()->flushGraphics();
- acedUpdateDisplay();
- acedAlert(L"Custom Regen Current Space");
- }
复制代码 |
|