文字のJustificationを修正


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

ECプログラミング処理は要素のプロパティに対し値の変更が行えます。この処理は要素の[プロパティ]ダイアログから手動の変更と同じ処理です。

ECプログラミング処理による文字のJustificationを修正例:

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

SchemaInfo schemaInfo(ECN::SchemaKey(L"BaseElementSchema", 1, 0), *ISessionMgr::GetActiveDgnFile());
ECN::ECSchemaPtr pSchema = DgnECManager::GetManager().LocateSchemaInDgnFile(schemaInfo, ECN::SchemaMatchType::SCHEMAMATCHTYPE_LatestCompatible);
ECN::ECClassCP pClass = pSchema->GetClassCP(L"MstnText");
DgnElementECInstancePtr pInstance = DgnECManager::GetManager().FindInstanceOnElement(eeh, *pClass, true); //polymorphic=true is important
pInstance->SetValue(L"Justification", ECValue((int)TextElementJustification::CenterMiddle));
pInstance->ScheduleWriteChanges(eeh);
eeh.ReplaceInModel(oldRef);

 Original Author:Mikihiko Tabata