The function Forma.getPresentationUnitSystem() is probably not working properly

The function Forma.getPresentationUnitSystem() is probably not working properly

vc6XFSA
Contributor Contributor
105 Views
2 Replies
Message 1 of 3

The function Forma.getPresentationUnitSystem() is probably not working properly

vc6XFSA
Contributor
Contributor

Hi!

 

We're using your API feature to sync the units your users use with our app.

vc6XFSA_1-1790763034904.png

 

import { Forma } from 'forma-embedded-view-sdk/auto';

export async function runFormaUnitsDemo() {

    const result = await Forma.getPresentationUnitSystem();
    console.log('[UNITS]', {
      result,
      type: typeof result,
    });
    return result;
 
}

However, even when the “Imperial” unit system is selected in the Forma UI settings, we're still getting metric value in the logs

vc6XFSA_0-1790762697484.png


Maybe we're missing something, or maybe it's a bug in the API.
I'd appreciate your response.

 

Best regards

Vsevolod

0 Likes
106 Views
2 Replies
Replies (2)
Message 2 of 3

sharafutdinov_di_dev
Enthusiast
Enthusiast

Hi Vsevolod,

You are not missing anything: in the current Forma build this looks like a host-side bug, not an issue with your code.

When your extension calls getPresentationUnitSystem(), the SDK asks the Forma host page for the value. The host does not answer from the project's unit setting. It answers from an internal feature flag, imperial-units, and while that flag is off every extension gets "metric" regardless of what the project uses. Forma's own panels read the project setting instead, which is why the Forma UI shows imperial while your extension is told metric.

Two more things to plan for:

  1. The SDK (0.96.0, the latest) has no unit change event. The method is a one-shot request, so even once this is fixed, re-read the value when your panel opens instead of caching it for the whole session.
  2. Until the host is fixed, getPresentationUnitSystem() will not tell you about imperial projects. A practical workaround is a metric/imperial switch in your own UI that defaults to the SDK value and saves the user's choice per project.

@evgenii_dobrovidov @kristoffer.dyrkorn could you pass this to whoever owns the embedded view host? The handler for unit-system/get-presentation-unit-system should return the project's unit setting, the same value Forma's own panels use.

Hope this helps.

Dinar Sharafutdinov · BIM coordinator · Revit API · Belgrade
Revit Model MCP   GitHub   LinkedIn   sharafutdinov.online
0 Likes
Message 3 of 3

bruno_miguel
Autodesk
Autodesk

Hi Vsevolod,

 

The host bug is fixed. getPresentationUnitSystem() now returns the project’s saved unit setting, the same value Forma’s own panels use.
The fix is live as of 20 minutes ago, so it should work without any changes on your side.


One thing still applies: there’s no unit-change event in the SDK, so re-read the value when your panel opens rather than caching it for the whole session.

 

Best regards,
Bruno · Forma Design Engineer

0 Likes