Request

Response

    Version 8 preview
    This page documents a preview of the Viewer SDK v8. APIs and content can still change before the final release.

    Feature Flags

    Feature flags let you enable or expose optional capabilities of the Viewer. They come in two flavors:

    • Enabling a functionality: turning the flag on activates the feature directly.
    • Exposing a capability: turning the flag on makes an option available (for example, a settings toggle), but the user still has to opt in before the capability is actually used.

    Feature flags are managed by the static class Autodesk.Viewing.FeatureFlags. It exposes set(), isEnabled(), and print() — see the FeatureFlags reference for the full method signatures.

    Note

    Feature flags must be set before you call Autodesk.Viewing.Initializer(). After initialization the flags become immutable: calling set() afterwards logs a warning and has no effect.

    Setting a Flag

    Set the feature flags you need before calling Autodesk.Viewing.Initializer(), then create your Viewer instance once the promise returned by the Initializer has resolved.

    var options = {
        env: 'AutodeskProduction2',
        api: 'streamingV2',
        getAccessToken: function(onTokenReady) {
            var token = 'YOUR_ACCESS_TOKEN';
            var timeInSeconds = 3600; // Use value provided by APS Authentication (OAuth) API
            onTokenReady(token, timeInSeconds);
        }
    };
    
    // Set feature flags BEFORE initialization.
    Autodesk.Viewing.FeatureFlags.set('FF_NAME', true);
    
    await Autodesk.Viewing.Initializer(options);
    
    var htmlDiv = document.getElementById('viewer');
    var viewer = new Autodesk.Viewing.GuiViewer3D(htmlDiv);
    viewer.start();
    
    Show More

    Available Public Flags

    The publicly available flag identifiers are exposed as constants on Autodesk.Viewing.PublicFeatureFlags — see the PublicFeatureFlags reference for the full list. You can pass either the constant or its string value to set().