马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
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");
}
|