プロダクト: | MicroStation | ||
バージョン: | CE update10 | ||
環境: | N/A | ||
エリア: | Programming | ||
サブエリア: | MDL |
配置するフォントを指定し、Unicode漢字の作成を行います。
UInt32 textColor=3;
double dang=0;
fontSize.x = fontSize.y = 1000.0;
origin.x = origin.y = origin.z = 0.0;
TextBlockPropertiesPtr tbProps = TextBlockProperties::Create(*ISessionMgr::GetActiveDgnModelP());
ParagraphPropertiesPtr paraProps = ParagraphProperties::Create(*ISessionMgr::GetActiveDgnModelP());
RunPropertiesPtr runProps = RunProperties::Create(*DgnTextStyle::GetActive(), *ISessionMgr::GetActiveDgnModelP());
tbProps->SetIsViewIndependent(false); // 拡張>ビューに依存
tbProps->SetIsVertical (true); //縦書き
paraProps->SetJustification(TextElementJustification::CenterMiddle);
runProps->SetColor(textColor);
runProps->SetFontSize(fontSize);
runProps->SetIsItalic(true);
dang=30.0 * PI / 180.0;
runProps->SetCustomSlantAngle(dang);
runProps->SetIsBold(true);
runProps->SetCharacterSpacingType(CharacterSpacingType::Absolute);
runProps->SetCharacterSpacingValue(1500.0);
DgnFontFilter filter = DgnFontFilter::TrueType;
// DgnFontCP newDgnFont = DgnFontManager::FindSystemFont(L"MS 明朝", filter);
DgnFontCP newDgnFont = DgnFontManager::FindSystemFont(L"UD デジタル 教科書体 N-B", filter);
runProps->SetFont(*newDgnFont);
TextBlockPtr textBlock = TextBlock::Create(*tbProps, *paraProps, *runProps, *ISessionMgr::GetActiveDgnModelP());
textBlock->SetProperties(*tbProps);
textBlock->SetUserOrigin(origin);
RotMatrix rMatrix = { 0 };
double dAngle= 50.0 * PI / 180.0; //50degree
DVec3d axis = DVec3d::From(0, 0, 1);
rMatrix=RotMatrix::FromVectorAndRotationAngle(axis, dAngle);
textBlock->SetOrientation(rMatrix); //<-- Text orientation
WString wStr=L"Place Text 文字の配置";
WPrintfString wrkMsg(L"wStr=%s length=%d",wStr.GetWCharCP(), wStr.length() );
mdlDialog_dmsgsPrint(wrkMsg.GetWCharCP());
textBlock->AppendText(wStr.GetWCharCP());
// Create the element...
EditElementHandle eeh;
if (TEXTBLOCK_TO_ELEMENT_RESULT_Success != TextHandlerBase::CreateElement(eeh, NULL, *textBlock))
{
return false;
}
eeh.AddToModel();
Original Author: | Mikihiko Tabata |