文字の配置位置を修正


 プロダクト:MicroStation
 バージョン:CE Update16
 環境:N/A
 エリア:Programming
 サブエリア:MDL

文字の配置位置を修正する場合、TextBlock APIを使用します。

EditElementHandle eeh(273L, ACTIVEMODEL);
  if (!eeh.IsValid())
   {
  mdlDialog_dmsgsPrint(L"Can't find the element you specified");
  return;
  }
ElementRefP oldRef = eeh.GetElementRef();

ITextEditP textEdit = eeh.GetITextEdit();
if (!textEdit || !textEdit->IsTextElement(eeh))
  {
  mdlDialog_dmsgsPrint(L"Your identified element is not a text element");
  return;
  }
ITextPartIdPtr textPart;
TextBlockPtr textBlock = textEdit->GetTextPart(eeh, *textPart);
if (textBlock.IsNull() || textBlock->IsEmpty())
  {
  mdlDialog_dmsgsPrint(L"Your text element has no content");
  return;
  }
DPoint3d ptOrigin = textBlock->GetUserOrigin();
ptOrigin.x += 10000.0;
textBlock->SetUserOrigin(ptOrigin);
textEdit->ReplaceTextPart(eeh, *textPart, *textBlock);
eeh.ReplaceInModel(oldRef);

 Original Author:Mikihiko Tabata