HRESULT BMText::CreateText(AcDbDatabase * pDb,const TextPro textPro, AcDbObjectId & oTextId)
{
AcDbText *pText = new AcDbText(textPro.ac3dTextPos,BIM::Tools::toWstring(textPro.sText).c_str(), textPro.acIdStyle, textPro.dHeight, textPro.dRotation);
pText->setWidthFactor(0.75);
pText->setJustification( AcDbText::kTextAlignmentCenter);
AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase() ->getBlockTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);
pBlockTableRecord->appendAcDbEntity(oTextId, pText);
pBlockTable->close();
pBlockTableRecord->close();
pText->close();
return E_FAIL;
}
I'm encountering an issue in my code where, after executing pText->setJustification(AcDbText::kTextAlignmentCenter);, the text position becomes offset by a certain distance. If I don't use this line of code, the text appears correctly at the expected coordinates.
I am using CAD version 2016