Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

RE: [CONNECT C++] TextBlock location and size

$
0
0

Hi,

regarding location of a textblock and height/width of text I have put an example together, which places a textnode at xyz(25,35,45) and assigns a textheight and textwidth of 8 mu to the second paragraph, I hope this helps using textblocks.

Best regards,

Artur

	double uorPerMaster = mdlModelRef_getUorPerMaster(MASTERFILE);
	DPoint3dCR point = { 25 * uorPerMaster, 35 * uorPerMaster, 45 * uorPerMaster };
	DgnModelP model = ISessionMgr::GetActiveDgnModelP();
	TextBlockPropertiesPtr tbProps = TextBlockProperties::Create(*model);
	ParagraphPropertiesPtr paraProps = ParagraphProperties::Create(*model);
	RunPropertiesPtr runProps = RunProperties::Create(*DgnTextStyle::GetActive(), *model);
	TextBlockPtr textBlock = TextBlock::Create(*tbProps, *paraProps, *runProps, *model);
	textBlock->SetProperties(*tbProps);
	textBlock->SetUserOrigin(point);
	textBlock->AppendText(L"This is a line of text");
	textBlock->AppendParagraphBreak();
	textBlock->AppendText(L"This is another line of text");

	DgnTextStylePtr tStyle = DgnTextStyle::GetActive();
	if (!tStyle.IsValid())
		return -1;
	tStyle->SetProperty(TextStyleProperty::TextStyle_Width, 8 * uorPerMaster);
	tStyle->SetProperty(TextStyleProperty::TextStyle_Height, 8 * uorPerMaster);
	CaretPtr caretFrom = textBlock->CreateStartCaret();
	caretFrom->MoveToNextParagraph();
	CaretPtr caretTo = textBlock->CreateEndCaret();
	textBlock->ApplyTextStyle(*tStyle.get(), true, *caretFrom.GetCR(), *caretTo.GetCR());
	textBlock->PerformLayout();
	EditElementHandle textElm;
	if (TEXTBLOCK_TO_ELEMENT_RESULT_Success == TextHandlerBase::CreateElement(textElm, NULL, *textBlock))
	{
		textElm.AddToModel();
	}







Viewing all articles
Browse latest Browse all 7260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>