acedEntSel(TEXT("\n"),en,pt); //选择第一个文字
acdbGetObjectId(text1Id,en);//给这个单行文字分配Id
acdbOpenObject(pEnt,text1Id,AcDb::kForWrite);//读写第一个文本
int colVal;//字体颜色
AcDbObjectId sty;//字体样式
double textheight;//字高
double textro;//字体旋转角
double textwidefactor;//字体宽度比例
if (pEnt->isA() == AcDbText::desc())
{
ptext1=AcDbText::cast(pEnt);//将实体付给单行文本
colVal = ptext1->colorIndex();//读取颜色
sty = ptext1->textStyle();//读取字体样式
textheight=ptext1->height();//读取字高
textro=ptext1->rotation();//读取旋转角
textwidefactor=ptext1->widthFactor();
}
if (pEnt->isA() == AcDbMText::desc())
{
pmtext1=AcDbMText::cast(pEnt);//将实体付给单行文本
colVal = pmtext1->colorIndex();//读取颜色
sty = pmtext1->textStyle();//读取字体样式
textheight=pmtext1->textHeight();//读取字高
textro=pmtext1->rotation();//读取旋转角
//textwidefactor=pmtext1->actualWidth();
}
acedEntSel(TEXT("\n请选择第二个文字"),en2,pt2);//选择第二个文字
acdbGetObjectId(text2Id,en2);
acdbOpenObject(pEnt2,text2Id,AcDb::kForWrite);//读写第二个文字
//ptext2=AcDbText::cast(pEnt2);
if (pEnt2->isA() == AcDbMText::desc())
{
pmtext2=AcDbMText::cast(pEnt2);
pmtext2->setColorIndex(colVal);//设置颜色
pmtext2->setTextStyle(sty);//设置字体样式
pmtext2->setTextHeight(textheight);//设置字高
pmtext2->setRotation(textro);//设置旋转角
//pmtext2->;
}
pMText->setWidth(width);
textwidth=ptext1->width();