Hi Experts,
I meet a issue where i need to read the ECInstance's properties, i can get the property name and values, but for some properties, i can't get the unit informaiton, what i need to get is the displayed value
exactly with that show in the Microstation's property panel.
my C# code to read the properties as below,
IEnumerable<IECProperty> properties = instance.ClassDefinition.Properties(true); foreach (IECProperty prop in properties) { IECPropertyValue propValue = instance.GetPropertyValue(prop.Name); IECProperty valuePro = propValue.Property; if (propValue != null) { string strCategory = ECInstanceUtil.GetPropertyInformation(prop); string type = prop.Type.Name.ToLower(); InstancProperty instanceProp = new InstancProperty(); instanceProp.Name = prop.Name; instanceProp.Type = type; instanceProp.DisplayLabel = prop.DisplayLabel; instanceProp.Description = prop.Description; instanceProp.Category = strCategory; string value = string.Empty; value = propValue.StringValue; } }
for the Three properties higlighed in the above screen shot, I just get the value without any unit informaiton, my question is how i can get the displayed value as show in Microstation's property panel?
I have read other thread in the forums such as https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/140064/connect-c-how-to-read-ec-units/424234#424234
but i did not get an answer for now, my model is attached,
/cfs-file/__key/communityserver-discussions-components-files/343173/_0A4E6568A267BD7E346C3A679263346C_-v1.dgn
thanks,
Rick
Rick,
please! edit your post and use Insert > Insert code tool to include the code snippet to your post. To share code as plain text is just annoying and makes readability quite complicated.
TIA Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
ok, i will update it. thanks
Hello Mr. Cheng,
I assume you can read Chinese and you can refer below post to get what you want:
https://communities.bentley.com/communities/other_communities/chinafirst/f/microstation-projectwise/159071/ce-c/474446#474446
yes, i can read chinese, and thanks for the reply, i will follow the refered link.
Hi Fu,
I check the link you share, i think it helps. but my question here is that is there any C# api for the below code,
IDgnECTypeAdapterR typeAdapter = IDgnECTypeAdapter::GetForProperty(*ecProp); IDgnECTypeAdapterContextPtr typeContext = IDgnECTypeAdapterContext::Create(*ecProp, *elemInst, ecProp->GetName().GetWCharCP()); typeAdapter.ConvertToString(wStr, ecVal, *typeContext);
i did not found the corresponding C# api for type adapter, do u know is there any C# api i can use. while i did found the C++ api as list in the above code.
Seems not. DgnECTypeAdapter only exists in C++ API.
ok, got it, thanks for the reply.
i will try it with C++ api.