Closed sweetld closed 3 years ago
It's this that I have been trying to do, but I'm clearly approaching it incorrectly, as it's having no effect..
Show your code?
I would have started with:
IModelApp.quantityFormatter.setActiveUnitSystem("metric", true);
but it appears that by default when you switch to a different iModel it will reset the settings (not sure if that matters in your case).
@bsteinbk
IModelApp.quantityFormatter.setActiveUnitSystem("metric", true);
You should be able to call this in the callback you pass into the onImodelConnected
prop on the viewer. So even if you change models it should always set the unit system to metric.
Thanks for your replies, this worked for me fine:
IModelApp.quantityFormatter.setActiveUnitSystem("metric", true);
Just so you know, I did not actually need to trigger the reload of the active tool in my case, so this also worked:
IModelApp.quantityFormatter.setActiveUnitSystem("metric");
I've been looking at changing the units that the iTwins Viewer displays in, as currently measurements are showing up in Imperial. Looking through the documentation, this seems to be the default, and if you want to display in Metric, then you have to change the setting.
It's this that I have been trying to do, but I'm clearly approaching it incorrectly, as it's having no effect...
I am trying to use the
setUnitFormattingSettingsProvider()
method with aLocalUnitFormatProvider
instance, which from what I understand in the documentation allows switching to Metric if you pass the constructor a true Boolean, so basically like this:IModelApp.quantityFormatter.setUnitFormattingSettingsProvider(new LocalUnitFormatProvider(new QuantityFormatter(true)));
Am I on the right track here, can anyone point me at an example, any advice would be really useful!