【问题标题】:Implementing Revit to Excel Exporter in Autodesk Forge在 Autodesk Forge 中实施 Revit to Excel Exporter
【发布时间】:2019-03-29 08:23:42
【问题描述】:

我正在尝试实施讨论过的 Revit 到 Excel 导出器 here。该按钮正在工作并将 urn 和令牌传递给

ForgeXLS.downloadXLSX(urn, token, callback /*Optional*/);

我收到一个错误“”GET“403(禁止)”

我正在扩展找到 here 的 Extensions Skeleton 教程。

范围是否可能存在问题...如果是,您能指导我如何调整我正在提取的访问令牌的范围吗?

ForgeXLSX.downloadXLSX 的代码是:

downloadXLSX: function (urn, token, status) {
    var fileName = decodeURIComponent(atob(urn).replace(/^.*[\\\/]/, '')) + '.xlsx';
    if (fileName.indexOf('.rvt') == -1) {
      if (status) status(true, 'Not a Revit file, aborting.');
      return;
    }

    if (status) {
      status(false, 'Preparing ' + fileName);
      status(false, 'Reading project information....');
    }

    this.prepareTables(urn, token, function (tables) {
      if (status) status(false, 'Building XLSX file...');

      var wb = new Workbook();
      jQuery.each(tables, function (name, table) {
        if (name.indexOf('<')==-1) { // skip tables starting with <
          var ws = ForgeXLS.sheetFromTable(table);
          wb.SheetNames.push(name);
          wb.Sheets[name] = ws;
        }
      });

      var wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: true, type: 'binary'});
      saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), fileName);

      if (status) status(true, 'Downloading...');
    })
  },

【问题讨论】:

    标签: autodesk-forge


    【解决方案1】:

    在范围方面,您需要两个 data:read bucket:read 才能充分访问模型元数据:

    范围不足的令牌以 403 结束:

    确保您的服务器在请求正文中正确设置范围以获取访问令牌。

    在调用 Forge 端点的过程中观察 URN 和 Token 变量的最佳选择是here at ForgeXLS.forgeGetRequest:

    【讨论】:

      【解决方案2】:

      经过一番挖掘(以及朋友的一些帮助)后,发现它毕竟是示波器。将 'data:read' 范围添加到 config.js 文件中的公共范围提供了所需的访问权限,并且导出器现在可以工作了。

       scopes: {
              // Required scopes for the server-side application
              internal: ['bucket:create', 'bucket:read', 'data:read', 'data:create', 'data:write'],
              // Required scope for the client-side viewer
              public: ['viewables:read', 'data:read']
          }
      

      【讨论】:

        猜你喜欢
        • 2021-10-16
        • 1970-01-01
        • 2021-12-25
        • 2021-07-10
        • 2020-04-10
        • 2017-03-15
        • 2018-07-16
        • 2019-02-09
        • 2021-05-08
        相关资源
        最近更新 更多