I am currently utilizing the Design Automation API to generate a model, and my next step is to load the viewable into the viewer using v6. Initially, this process works perfectly fine. However, I encounter an issue where the viewer continuously loads the same .svf file after the first time. I have attempted deleting the manifest, passing true to the x-ads-force parameter, and including the If-Modified-Since header when initializing the viewer.
I am working with the .NET SDK.
DerivativesAPI.Translate(Job, True)
Forge Javascript....
var viewer;
function showModel(AccessToken, urn) {
var options = {
env: 'AutodeskProduction',
accessToken: AccessToken,
api: 'derivativeV2'
};
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 available 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);
}