Hi,
I am using two kind of methods to draw text. I got different drawing.
I used old "mdltext_Create" API. The drawing show correctly.
DgnPlatform::TextParamWide textParam; textParam.font = scGetTextFontFromName(pReader, Font); textParam.just = TextElementJustification::LeftBaseline; textParam.lineStyle_deprecated = 0; textParam.viewIndependent = 0; DgnModelP model = ISessionMgr::GetActiveDgnModelP(); mdlText_create( pElement, NULL, WTxtString, &Point, &Matrix, &TextSize, &textParam, NULL, model );
I tried to use CONNECT SDK API TextBlock. The text drawing was offset some value.
DgnModelRefP modelRef = ISessionMgr::GetActiveDgnModelP(); double scale = mdlModelRef_getUorPerMaster(modelRef); DPoint2d fontSize; fontSize.x = Size * scale; fontSize.y = Size * scale; Point.x = Point.x * scale; Point.y = Point.y * scale; Point.z = Point.z * scale; TextBlockPropertiesPtr tbProps = TextBlockProperties::Create(*ISessionMgr::GetActiveDgnModelP()); ParagraphPropertiesPtr paraProps = ParagraphProperties::Create(*ISessionMgr::GetActiveDgnModelP()); RunPropertiesPtr runProps = RunProperties::Create(*DgnTextStyle::GetActive(), *ISessionMgr::GetActiveDgnModelP()); tbProps->SetIsViewIndependent(true); paraProps->SetJustification(TextElementJustification::LeftBaseline); runProps->SetColor(Color); runProps->SetFontSize(fontSize); runProps->SetFont(*pDGNFont); TextBlockPtr textBlock = TextBlock::Create(*tbProps, *paraProps, *runProps, *ISessionMgr::GetActiveDgnModelP()); if( textBlock.IsValid() ) { textBlock->SetUserOrigin(Point); textBlock->SetOrientation(Matrix); textBlock->AppendText(WTxtString); } EditElementHandle textElm; TextBlockToElementResult textReturn = TextHandlerBase::CreateElement(textElm, NULL, *textBlock); if( TextBlockToElementResult::TEXTBLOCK_TO_ELEMENT_RESULT_Success == textReturn) {
Anybody can help me to locate my code bug?
Best,