IDgnECTypeAdapter::GetStandardValues fills a StandardValuesCollection from the MstnPropertyFormatter schema. Here's a fragment of XML...
<StandardValues xmlns="EditorCustomAttributes.01.00"> <ValueMap> <ValueMap> <Value>-1</Value> <DisplayString>(Use Active Master Units)</DisplayString> </ValueMap> ... 16 more </ValueMap> </StandardValues>
But StandardValuesCollection is a bvector of WString. What it gets is a list of DisplayStrings. It ignores the integer Value element.
Are the integer Value elements relevant, and if so how do I obtain them?
Unknown said:What are you trying to accomplish?
Following your previous hints, I'm exploring how to get a custom display string from a standard element property. For example, a closed element seems to belong to an EC AreaClass in the MstnPropertyFormatter schema. ECProperty Units has a list of StandardValues including Use Active Master Units, Acres and others. How do I obtain a string that measures a closed element in, say, Acres?
I find it rather easy to become lost in the forest of DgnECTypeAdapter, ECEnabler, DgnECInstance, DgnECTypeAdapterContext and ECProperty.
Regards, Jon Summers LA Solutions
Unknown said:Create an ECInstance of AreaClass
I'm stumped. I think that I need a DgnECInstanceEnabler in order to create an ECInstance. Here's what I have so far...
if (TextPropertyManager::GetMstnPropertyFormatterSchema (formatSchema)) // help function { ECN::ECClassCP formatClass = formatSchema->GetClassCP (L"AreaClass"); //trace: got EC Class 'AreaClass' Display Label 'Closed Elements' const bool& IncludeBaseClasses { true }; ECPropertyP prop = formatClass->GetPropertyP (L"Units", IncludeBaseClasses); //trace: Schema 'MstnPropertyFormatter' Class 'AreaClass' has property 'Units' DgnECManagerR manager = Bentley::DgnPlatform::DgnECManager::GetManager(); DgnECInstanceEnablerP formatEnabler = manager.ObtainInstanceEnabler (*formatClass, *GetActiveDgnFile ()); // formatEnable == nullptr }
What have I missed?
Answer Verified By: Jon Summers
Unknown said:All you need is an IECInstance...
Finally I arrived at my destination...
An IECInstance instance is created from ECClass AreaClass and its Units and Accuracy properties set to show two decimal points and Acres measurement unit. The resulting formatter instance is passed to TextField::CreateForElement to make a formatted text field.
Thanks for all your help and guidance!
Hi Jon, I see u have a lot comments/post about the unit, I meet a similar issue from my side, which i just want to get the unit display string,
https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/179320/how-to-get-the-display-property-value-for-ce-version-10-07-with-c
can u help me out there?
thanks,
Rick