Autodesk Forge Design Automation/Model 衍生品 API - 查看器缓存 svf 文件

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

我正在使用设计自动化 API 生成模型,然后我不想将可视项加载到查看器中,我使用的是 v6。当我第一次这样做时它工作正常但查看器将继续始终加载相同的 .svf 文件,我尝试删除清单,我将 true 传递给 x-ads-force 参数并且我'在初始化查看器时已经包含 If-Modified-Since header...

我正在使用 .net SDK

DerivativesAPI.Translate(Job, True)

锻造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);
 }

请更改此行以加载其他 SVF:

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

要打开运行时,您可以使用 Autodesk.DocumentBrowser

var config = {
    extensions: ['Autodesk.DocumentBrowser'].concat( initGeom.extensions() )
};
viewer = new Autodesk.Viewing.Private.GuiViewer3D(viewerDiv, config);

最后,请注意Publish Settings of the RVT model, Model Derivative API will export view sets chosen in the Publish Settings only. If there is no predefined view sets of the Publish Settings,它会默认使用默认的3D视图导出。

这是因为我 运行 从 Visual Studio 开始处于调试模式,切换到发布模式解决了问题