简体   繁体   English

修改模型的属性 Autodesk-Forge

[英]Modify Properties of a Model Autodesk-Forge

I am working on an app to upload a model, then retrieve and allow user to modify its properties via Excel/CSV/JSON.我正在开发一个应用程序来上传模型,然后检索并允许用户通过 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.在这里看到模型是只读的,并且 PATCH 不是为了允许直接修改模型对象属性,而是更侧重于文档。

Is this understanding correct?这种理解是否正确?

If so, can Forge host JSON?如果是这样,Forge 可以托管 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.目前的计划是导出数据,在 excel 中修改,上传/转换为 JSON,将其存储(某处),然后在 Forge 中显示来自 JSON 数据的属性。 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!是的,所有通过 Forge Model Derivative API 提取的文件都是只读的! And no, you have to host such web API server yourself, Forge didn't have the capability to host customers' web server.不,您必须自己托管这样的 Web API 服务器,Forge 没有能力托管客户的 Web 服务器。

You can check my demo for Custom Props Panel here and its' screencast:您可以在此处查看我的自定义道具面板演示及其截屏视频:

在 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 .制作托管您的财产数据的 Web API,我在此演示中使用模拟 JSON API 服务器,请参阅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在自定义属性面板中获取您自己的属性服务,请参阅 properties/scripts/AdnPropsPanel.js 的第 33 行

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM