Search code examples
javascript.netautodesk-forgeautodesk-viewerautodesk-model-derivative

Autodesk Forge Design Automation/Model Derivative API - Viewer caching svf file


I'm using the Design Automation API to generate a model, i then wan't to load the viewable into the viewer, im using v6. When i do this the first time it works fine but the viewer will then continue to always load the same .svf file, i've tried deleting the manifest, i'm passing true to to the x-ads-force parameter and i've included the If-Modified-Since header when initializing the viewer...

im using the .net SDK

DerivativesAPI.Translate(Job, True)

Forge Javascript....

var viewer;

function showModel(AccessToken, urn) {
var options = {
    env: 'AutodeskProduction',
    accessToken: AccessToken,
    api: 'derivativeV2'    // for models uploaded to EMEA change this option to 'derivativeV2_EU'
};
var documentId = 'urn:' + urn;
Autodesk.Viewing.endpoint.HTTP_REQUEST_HEADERS['If-Modified-Since'] = 'Sat, 29 Oct 1994 19:43:31 GMT';
Autodesk.Viewing.Initializer(options, function onInitialized() {
    Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
});
}

function onDocumentLoadSuccess(doc) {

// A document contains references to 3D and 2D geometries.
var geometries = doc.getRoot().search({ 'type': 'geometry' });
if (geometries.length === 0) {
    console.error('Document contains no geometries.');
    return;
 }

// Choose any of the avialable geometries
var initGeom = geometries[0];

// Create Viewer instance
var viewerDiv = document.getElementById('MyViewerDiv');
var config = {
    extensions: initGeom.extensions() || []
};
viewer = new Autodesk.Viewing.Private.GuiViewer3D(viewerDiv, config);

// Load the chosen geometry
  var svfUrl = doc.getViewablePath(initGeom);
   var modelOptions = {
    sharedPropertyDbPath: doc.getPropertyDbPath()
   };
   viewer.start(svfUrl, modelOptions, onLoadModelSuccess, onLoadModelError);

   }


function onDocumentLoadFailure(viewerErrorCode) {
console.error('onDocumentLoadFailure() - errorCode:' + viewerErrorCode);
}


function onLoadModelSuccess(model) {
console.log('onLoadModelSuccess()!');
console.log('Validate model loaded: ' + (viewer.model === model));
console.log(model);
}


function onLoadModelError(viewerErrorCode) {
console.error('onLoadModelError() - errorCode:' + viewerErrorCode);
 }

Solution

  • Its because i was running in Debug mode from Visual Studio, switching to release mode solved the issue