|
- void getTextStrWidth()
- {
- char str[132];
- int rt = acedGetString(true, "/nEnter a string: ", str);
- if (rt != RTNORM)
- {
- acutPrintf("/nInvalid input, try again.");
- return;
- }
- AcGiTextStyle iStyle;
- AcDbTextStyleTable* pTable = NULL;
- AcDbTextStyleTableRecord* pRecord = NULL;
- try {
- ARXOK(curDoc()->database()->getTextStyleTable(pTable,
- AcDb::kForRead));
- const char styleName[] = "STANDARD";
- ARXOK(pTable->getAt(styleName, pRecord, AcDb::kForRead));
- ARXOK(fromAcDbTextStyle(iStyle, pRecord->objectId()));
- pRecord->close();
- pTable->close();
- }
- catch (const Acad::ErrorStatus es)
- {
- acutPrintf("/nError: %s", acadErrorStatusText(es));
- pRecord->close();
- pTable->close();
- }
- AcGePoint2d pt = iStyle.extents(str, Adesk::kFalse, _tcslen(str),
- Adesk::kTrue);
- // get the width
- acutPrintf("/nText string width is: /t.", pt.x);
- // get the height too
- acutPrintf("/nText string height is: /t.", pt.y);
- }
- //declare the following inline function in a header file
- inline void ARXOK(Acad::ErrorStatus what) throw(Acad::ErrorStatus)
- {
- if (what != Acad::eOk)
- throw what;
- }
复制代码 |
|