- 积分
- 12459
- 明经币
- 个
- 注册时间
- 2003-5-28
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2004-11-27 17:18:00
|
显示全部楼层
回复
创建文字样式的一段例子:
static void setTextStyle_test(void) { // Add your code for command setTextStyle._test here Acad::ErrorStatus es; AcDbTextStyleTable *pTsTable;
es = curDoc()->database()->getSymbolTable(pTsTable,AcDb::kForRead); if (es != Acad::eOk) { AfxMessageBox("Couldn't get the text style table."); }
CString theFont = "宋体";
if (!pTsTable->has((LPTSTR)(LPCSTR)theFont)) { AcDbTextStyleTableRecord *pStyle = new AcDbTextStyleTableRecord;
pStyle->setFont((LPTSTR)(LPCTSTR)theFont,Adesk::kFalse,Adesk::kFalse,0,34); pStyle->setFileName(theFont); pStyle->setBigFontFileName(theFont);
pStyle->setTextSize(8); pStyle->setXScale(2); pStyle->setObliquingAngle(0); pStyle->setName(theFont); pStyle->setIsShapeFile(Adesk::kFalse); pStyle->setIsVertical(Adesk::kFalse);
pTsTable->upgradeOpen(); es = pTsTable->add(pStyle); if (es != Acad::eOk) { CString message; message.Format("%d",es); AfxMessageBox(message); } pStyle->close(); }
// Get the style record we just created, to ensure that it was // added properly to the style table. AcDbObjectId styleId;
es = pTsTable->getAt(theFont,styleId); if (es != Acad::eOk) { CString message; message.Format("%d",es); AfxMessageBox(message); } else { AfxMessageBox("Got the style!"); }
pTsTable->close();
AcDbText * text = new AcDbText(AcGePoint3d(10,10,0),"你好",styleId,10,0); AcDbBlockTable *pBlockTable; acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable,AcDb::kForRead); AcDbBlockTableRecord *pBlockTableRecord; pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite); pBlockTable->close(); AcDbObjectId textId; es = pBlockTableRecord->appendAcDbEntity(textId,text); text->close(); pBlockTableRecord->close(); }
如图:
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|