|
发表于 2006-6-14 00:41:00
|
显示全部楼层
AcDbObjectId CLjDwg::AddTextStyle(const char* strName,
const char* strStype,
const char* strBigName,
const double dHeight,
const double dFactor,
AcDbDatabase* pDb)
{
AcDbObjectId idTextStyle=NULL;
AcDbTextStyleTable *pTable=NULL;
AcDbTextStyleTableRecord *pTableRecord;
if (pDb==NULL)
pDb=acdbCurDwg();
pDb->getTextStyleTable(pTable,AcDb::kForWrite);
if(pTable==NULL)
{
AfxMessageBox("Fonttable open wrong");
return idTextStyle;
}
// 生成新的图层表记录
Acad::ErrorStatus es;
pTable->getAt(ACDB_MODEL_SPACE,pTableRecord,AcDb::kForWrite);
if(pTable->has(strName))
{
pTable->getAt(strName,idTextStyle);
}
else
{
pTableRecord=new AcDbTextStyleTableRecord;
es = pTableRecord->setName(strName);
if(CString(strStype).Find(_T(".shx")) != -1
|| CString(strStype).Find(_T(".SHX")) != -1)
{
char szPath[MAX_PATH];
if (ads_findfile(strStype,szPath) != RTNORM)
{
ads_printf("Could not find file %s.\n", strStype);
}
else
{
es = pTableRecord->setFileName(strStype);
}
if(CString(strBigName) != _T(""))
{
char szPath[MAX_PATH];
if (ads_findfile(strBigName,szPath) != RTNORM)
{
ads_printf("Could not find file %s.\n", strBigName);
}
else
{
es = pTableRecord->setBigFontFileName(strBigName);
}
}
}
else
{
es = pTableRecord->setFont(strStype,FALSE,FALSE,200,100);
}
pTableRecord->setTextSize(dHeight);
pTableRecord->setXScale(dFactor);
es = pTable->add(idTextStyle,pTableRecord);
pTableRecord->close();
}
pTable->close();
return idTextStyle;
}
|
|