如何从Autodesk Platform Services映射data_type枚举值至字符串类型?
解决方案
1. 官方枚举值与字符串类型映射表
Autodesk Platform Services中data_type字段的枚举数字对应以下字符串类型,可直接使用该映射关系:
0:undefined1:boolean2:integer3:double4:string5:date6:guid7:vector8:point9:matrix10:object11:enum12:blob
2. 实现转换逻辑
目前没有专门的API提供该枚举转换功能,需在代码中手动实现映射逻辑。以下是JavaScript示例:
const dataTypeMapping = { 0: 'undefined', 1: 'boolean', 2: 'integer', 3: 'double', 4: 'string', 5: 'date', 6: 'guid', 7: 'vector', 8: 'point', 9: 'matrix', 10: 'object', 11: 'enum', 12: 'blob' }; // 针对你提供的示例参数转换 const elevationParam = { "id": 33, "name": "Elevation", "category": "Constraints", "data_type": 3, "data_type_context": "autodesk.unit.unit:millimeters-1.0.1", "description": null, "display_name": "Elevation", "flags": 0, "display_precision": 1, "forge_parameter": null }; const dataTypeStr = dataTypeMapping[elevationParam.data_type]; // 结果为 'double'
内容的提问来源于stack exchange,提问作者chuongmep
相关产品推荐
相关产品推荐

