修改模型的属性 Autodesk-Forge [英] Modify Properties of a Model Autodesk-Forge

查看:20
本文介绍了修改模型的属性 Autodesk-Forge的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序来上传模型,然后检索并允许用户通过 Excel/CSV/JSON 修改其属性.我看到

关键概念是:

  1. 制作托管您的财产数据的 Web API,我在此演示中使用模拟 JSON API 服务器,请参阅 forge-au-sample/mock-server.
  2. 在自定义属性面板中获取您自己的属性服务,请参阅 第 33 行的属性/脚本/AdnPropsPanel.js

    getRemoteProps( dbId ) {返回新的承诺((解决,拒绝)=> {const srvUrl = getServerUrl();fetch(`${ srvUrl }/api/props?_expand=dataType&dbId=${ dbId }`, {方法:'获取',标题:新标题({'内容类型':'应用程序/json'})}).then( ( 响应 ) => {如果(响应.状态 === 200){返回 response.json();} 别的 {返回拒绝(新错误(响应.statusText));}}).then( ( 数据 ) => {if( !data ) return reject( new Error( 'Failed to fetch properties from the server' ) );返回解析(数据);}).catch((错误)=>拒绝(新错误(错误)));});}

I am working on an app to upload a model, then retrieve and allow user to modify its properties via Excel/CSV/JSON. I see here that models are read only and that PATCH is not intended to allow direct modification of model object properties, but is more focused on documents.

Is this understanding correct?

If so, can Forge host JSON?

The current plan is to export the data, modify in excel, upload/convert into JSON, store it (somewhere) and then display in Forge the properties from the JSON data. But we are looking for a simple place to host the new external db.

解决方案

Yes, all extracted files via Forge Model Derivative API is read-only! And no, you have to host such web API server yourself, Forge didn't have the capability to host customers' web server.

You can check my demo for Custom Props Panel here and its' screencast:

The key concepts are:

  1. Make a Web API hosting your property data, I use a mock JSON API server in this demo, see forge-au-sample/mock-server.
  2. Fetch your own property service in a custom property panel, see line 33 of the properties/scripts/AdnPropsPanel.js

    getRemoteProps( dbId ) {
      return new Promise(( resolve, reject ) => {
        const srvUrl = getServerUrl();
        fetch( `${ srvUrl }/api/props?_expand=dataType&dbId=${ dbId }`, {
          method: 'get',
          headers: new Headers({
            'Content-Type': 'application/json'
          })
        })
          .then( ( response ) => {
            if( response.status === 200 ) {
              return response.json();
            } else {
              return reject( new Error( response.statusText ) );
            }
          })
          .then( ( data ) => {
            if( !data ) return reject( new Error( 'Failed to fetch properties from the server' ) );
    
            return resolve( data );
          })
          .catch( ( error ) => reject( new Error( error ) ) );
      });
    } 
    

这篇关于修改模型的属性 Autodesk-Forge的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆