-
|
A while back I posted a discussion to the iTwins forum about getting UOM for a model. The answers given by Colin and Grigas were great and helped me understand what it would take to potentially read UOM/Units at a model level. Since that post, my project requirements have changed a little. Now, in our system we have a need to run calculations on both metric values (the raw - full precision value we get from iTwins - getElementProperties()) and an imperial (raw value converted to imperial) value for a given model element property. I’m also trying to relate the KindOfQuantity information from the forum discussion, to what we are needing to do when pulling the data. What I’m hoping for is to end up with a property that has the following: To do these types of conversions at the time we’re reading the data, it seems like we’d need to know dimension (length, volume, weight, etc), which I believe you call phenomenon. Based on dimension we could convert the raw value to an imperial raw value and load both dimension and the new imperialValue into our system for future calculations. There may be a better way to do all of this, and there may be some built-in functionality in iTwins that we can leverage to get what the result needed. Can you please give me some guidance and how to achieve what we’re looking to do? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
|
Hello, If I got this right, it seems you'd like to go from querying for a KindOfQuantity like Grigas had a good example in this reply, if you are looking to use the Presentation APIs. I noticed you'd like to also know the phenomenon (what you refer as dimension) of the units associated with the KindOfQuantity? I have a quick example here that could show the workflow: const koq = field.properties[0].property.kindOfQuantity; // a KindOfQuantityInfo, AecUnits.LENGTH for example
const persistenceUnitName = koq.persistenceUnit; // Could be Units.M
const persistenceUnit = await schemaUnitsProvider.findUnitByName(peristenceUnitName);
const phenomenon = persistenceUnit.phenomenon; // it would be Units.LENGTH, other imperial units like Units.US_SURVEY_FT or UNITS.FT will have the same phenomenon tooThis link points to our Units schema, which all iModels will have. You can see by the highlighted portions that all of these different units that measure length have the same phenomenon that you would need. Let me know if this wasn't too clear or doesn't fit what you were looking for. |
Beta Was this translation helpful? Give feedback.
Hello,
If I got this right, it seems you'd like to go from querying for a KindOfQuantity like
Lengthin your case, and be able to format Length values from metric to imperial (in code)?Grigas had a good example in this reply, if you are looking to use the Presentation APIs.
I noticed you'd like to also know the phenomenon (what you refer as dimension) of the units associated with the KindOfQuantity?
KindOfQuantityInfocontains the EC fullname for the persistence unit. You could then utilize a unitsProvider, like a SchemaUnitsProvider, to lookup that unit, and then retrieve the name for the phenomenon.I have a quick example here that could show the workflow: