static void CTx2Mtx_tx2mtx(void)
{
struct resbuf eb;
TCHAR sbuf[10];
eb.restype=0; // имя примитива
_tcscpy(sbuf,_T("TEXT"));
eb.resval.rstring=sbuf;
eb.rbnext=0;
ads_name ss;
if (acedSSGet (ACRX_T("_I"), NULL, NULL, &eb, ss) != RTNORM )
{
if(acedSSGet(0,0,0,&eb,ss) !=RTNORM)
{
//acutRelRb(&eb);
return;
}
}
//acutRelRb(&eb);
long length=0;
if((acedSSLength(ss,&length)!=RTNORM)||(length==0))
{
acedSSFree(ss);
return;
}
// Код
ads_name ent;
AcDbObjectId id = AcDbObjectId::kNull;
// Walk through the selection set and open each entity
for (long i = 0; i < length; i++)
{
if (acedSSName(ss,i,ent) != RTNORM) continue;
if (acdbGetObjectId(id,ent) != Acad::eOk) continue;
AcDbEntity* pEnt = NULL;
if (acdbOpenAcDbEntity(pEnt,id,AcDb::kForWrite) != Acad::eOk)
continue;
if ( !pEnt->isKindOf (AcDbText::desc ()) )
{
pEnt->close();
continue;
}
AcDbText* pT=AcDbText::cast(pEnt);
AcDbMText* pMt=new AcDbMText();
pMt->setPropertiesFrom(pEnt); //копирование Color, Layer, Linetype, Linetype scale, Visibility
{AcGePoint3d Point=pT->position();
pMt->setLocation(Point);
}
{//AcGePlane plan;
AcGeVector3d Norm=pT->normal();
//AcDb::Planarity curvConfig;
//pT->getPlane(plan,curvConfig);
pMt->setNormal(Norm);
}
{
double Heitgh=pT->height();
pMt->setTextHeight(Heitgh);
}
{
double rot=pT->rotation();
pMt->setRotation(rot);
}
{
AcDbObjectId textstyle=pT->textStyle();
pMt->setTextStyle(textstyle);
}
{
//const ACHAR* content=pT->textStringConst();
ACHAR* content=pT->textString();
pMt->setContents(content);
acdbFree (content);
}
//2.pText->setBackgroundFill(true);
//3.pText->setUseBackgroundColor(false);
//4.pText->setBackgroundScaleFactor(1.0);
//5.pText->setBackgroundFillColor(backColor);
//10.pText->setAttachmentMovingLocation(AlignLoc);
AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);
pBlockTable->close();
//AcDbObjectId tempId;
//pBlockTableRecord->appendAcDbEntity(tempId,pMt);
pBlockTableRecord->appendAcDbEntity(pMt);
pBlockTableRecord->close();
pMt->close();
pEnt->erase(); pEnt=0;
}
acedSSFree(ss);
ads_regen();
return;
}