Modify Properties of a Model Autodesk-Forge

余生长醉 提交于 2019-12-11 08:05:33

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/52844714/modify-properties-of-a-model-autodesk-forge

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!