【问题标题】:Autodesk Forge Design Automation/Model Derivative API - Viewer caching svf fileAutodesk Forge 设计自动化/模型衍生 API - 查看器缓存 svf 文件
【发布时间】:2020-05-03 08:43:11
【问题描述】:

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

我使用 .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);
 }

【问题讨论】:

    标签: javascript .net autodesk-forge autodesk-viewer autodesk-model-derivative


    【解决方案1】:

    请更改此行以加载其他 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);
    

    最后,请注意 RVT 模型的 Publish Settings,模型衍生 API 将仅导出在 Publish Settings 中选择的视图集。如果Publish Settings没有预定义的视图集,则默认使用默认的3D视图导出。

    【讨论】:

    • 对不起,我应该澄清一下,我正在加载发明者 .ipt 文件的 svf。我不想加载不同的视图,我想加载一个新生成的相同模型的 svf。
    • 如果您的 urn 相同,请尝试清除浏览器缓存。
    【解决方案2】:

    因为我在 Visual Studio 的调试模式下运行,切换到发布模式解决了问题

    【讨论】:

      猜你喜欢
      • 2017-12-06
      • 2021-12-31
      • 2021-03-09
      • 2018-11-07
      • 2020-05-27
      • 2020-11-10
      • 2018-01-17
      • 2021-02-25
      • 1970-01-01
      相关资源
      最近更新 更多