How to place a text object in center of a closed polyline? When I set center’s coordinates as the position of the text, the text is placed starting from this point to the right.

  1. FAQ
  2. »
  3. Text and Font Questions

Use pText->setAlignmentPoint(OdGePoint3d(outlineCenter.x() , outlineCenter.y(), outlineCenter.z())) and set text alignment by next way

pText->setHorizontalMode(OdDb::TextHorzMode::kTextCenter );
pText->setVerticalMode(OdDb::TextVertMode::kTextVertMid) ;

Method adjustAlignment(); is called while text entity is closed but may be called directly after append in block

m_blockTableRecordPtr->appendOdDbEntity(pText); 
pText->adjustAlignment(NULL);