//获得TEXT文本的实际宽度 double GetTextTrueWidth(CString sText, double dTextHeight, CString sTextStyle) { AcGiTextStyle TextStyle; if(!sTextStyle.IsEmpty()) { if(fromAcDbTextStyle(TextStyle, LPCTSTR(sTextStyle)) != Acad::eOk) return 0.0; } else { if(fromAcDbTextStyle(TextStyle, acdbHostApplicationServices()->workingDatabase()->textstyle()) != Acad::eOk) return 0.0; } TextStyle.setTextSize(dTextHeight); TextStyle.loadStyleRec(); AcGePoint2d Pt = TextStyle.extents(LPCTSTR(sText), Adesk::kTrue, -1, Adesk::kFalse);
return Pt.x; }
|