问题
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:
- Make a Web API hosting your property data, I use a mock JSON API server in this demo, see forge-au-sample/mock-server.
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