Modify Properties of a Model Autodesk-Forge

2019-07-22 17:11发布

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条回答
We Are One
2楼-- · 2019-07-22 17:59

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:

View on Youtube

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 ) ) );
      });
    } 
    
查看更多
登录 后发表回答