如何从Autodesk模型衍生API的响应中识别提取的obj文件?

时间:2019-07-05 06:37:20

标签: javascript autodesk-forge autodesk-model-derivative

在模型派生API(使用DbIds进行OBJ提取)中,我使用API​​检索了OBJ URN。如下所示,它返回obj,mtl及其zip的所有子级URN。每个孩子确实都有自己的向导,我们如何确定最近的拔牙?

我附加了整个响应JSON。我正在寻找的是第二个obj文件,该文件已使用“ 17,19,21,22,23 ...”之类的多个dbid提取。第一个子obj是很久以前创建的。如何区分新的obj。因为GUID对于每个节点都是不同的。如何确定哪个GUID.obj属于我想要的提取。

**编辑**  我正在寻找标识提取的波前对象文件(而不是从元数据中获取的objectid和名称)。假设如果我从一个模型中提取了2个目标文件,那么在完成目标文件几何图形提取作业之后,将生成6个文件并将其存储在存储桶中。

  1. 第一个.obj(guid = /output/geometry/e72fa6b3-4fc2-3c86-8424-5d0755539c0d.obj)
  2. 第一个.mtl
  3. 第一个.zip
  4. 第二个.obj
  5. 第二.mtl
  6. 第二个.zip

每个文件都具有不同的GUID.Type作为名称。并且那些guid是随机的,在调用提取API或获得进度时不会显示。

这些显示在下面的JSON文件中。现在假设我从一个模型中提取了10个不同的目标文件。这意味着将在存储区30中生成新文件URN。 而且变得越来越难以识别。

如果我从模型中提取obj几何,则解决方案应该是,我应该获取特定的obj,mtl,zips guid。如果我仅获得3个ID,则可以将其映射并从存储桶中下载。 现在发生的是,在调用get manifest GET :urn/manifest之后,我将获得所有obj的guid(假设为30)。而且我不了解哪个obj文件属于哪个提取。

{
  "type": "manifest",
  "hasThumbnail": "true",
  "status": "success",
  "progress": "complete",
  "region": "US",
  "urn": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZXh0cmFjdC1hdXRvZGVzay1pby0yMDE3MnVvbm5paWJkd2t1Z25ydGVvZGFjN2FpeWhwdjdrd20vcm1lX2FkdmFuY2VkX3NhbXBsZV9wcm9qZWN0Lm53ZA",
  "version": "1.0",
  "derivatives": [{
    "name": "rme_advanced_sample_project.nwd",
    "hasThumbnail": "true",
    "status": "success",
    "progress": "complete",
    "outputType": "svf",
    "children": [{
      "guid": "763d96f1-0812-451d-b3a1-a51a27eba53b",
      "name": "rme_advanced_sample_project.rvt",
      "hasThumbnail": "true",
      "role": "3d",
      "viewableID": "rme_advanced_sample_project.rvt",
      "progress": "complete",
      "useAsDefault": true,
      "status": "success",
      "type": "geometry",
      "children": [{
        "guid": "1e172e73-2305-4eb8-9954-eeab8217a8d3",
        "name": "Default",
        "hasThumbnail": "true",
        "role": "3d",
        "camera": [-86.09573364257812, -79.89456176757812, 139.12220764160156, 70.56798553466797, 76.76915740966797, -17.541505813598633, 0.40824830532073975, 0.40824830532073975, 0.8164966106414795, 1.664323329925537, 0.785398006439209, 1, 0],
        "useAsDefault": true,
        "status": "success",
        "type": "view",
        "children": [{
          "guid": "f2054c5f-10b8-457b-a927-23b69107dcd7",
          "role": "thumbnail",
          "mime": "image/png",
          "resolution": [100, 100],
          "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZXh0cmFjdC1hdXRvZGVzay1pby0yMDE3MnVvbm5paWJkd2t1Z25ydGVvZGFjN2FpeWhwdjdrd20vcm1lX2FkdmFuY2VkX3NhbXBsZV9wcm9qZWN0Lm53ZA/output/0/0_100.png",
          "type": "resource"
        }, {
          "guid": "20625548-d014-4d29-8e50-4d61a1759a60",
          "role": "thumbnail",
          "mime": "image/png",
          "resolution": [200, 200],
          "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZXh0cmFjdC1hdXRvZGVzay1pby0yMDE3MnVvbm5paWJkd2t1Z25ydGVvZGFjN2FpeWhwdjdrd20vcm1lX2FkdmFuY2VkX3NhbXBsZV9wcm9qZWN0Lm53ZA/output/0/0_200.png",
          "type": "resource"
        }, {
          "guid": "48675a6a-f2ec-4748-b22c-200b72cd06a8",
          "role": "thumbnail",
          "mime": "image/png",
          "resolution": [400, 400],
          "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZXh0cmFjdC1hdXRvZGVzay1pby0yMDE3MnVvbm5paWJkd2t1Z25ydGVvZGFjN2FpeWhwdjdrd20vcm1lX2FkdmFuY2VkX3NhbXBsZV9wcm9qZWN0Lm53ZA/output/0/0_400.png",
          "type": "resource"
        }]
      }, {
        "guid": "77850512-9e8b-4d09-bb1a-45706ad5b7e6",
        "name": "3D View",
        "hasThumbnail": "false",
        "role": "viewable",
        "progress": "0% complete",
        "status": "success",
        "type": "folder",
        "children": [{
          "guid": "ebf9f756-6cfa-4858-9787-e3af9c8424c3",
          "name": "3D Duct & Equipment",
          "role": "3d",
          "camera": [61.56271743774414, 38.53883743286133, 9.783880233764648, 59.46215057373047, 40.639404296875, 7.683313846588135, -0.40824830532073975, 0.40824830532073975, 0.8164966106414795, 1, 45, 227.96743774414062, 1],
          "status": "success",
          "type": "view"
        }, {
          "guid": "54d5a270-f330-4446-a482-1079312d8518",
          "name": "Main Electrical Distribution",
          "role": "3d",
          "camera": [91.54497528076172, -63.42673110961914, -34.64605712890625, 46.680015563964844, 38.5232048034668, -66.7026596069336, -0.11140129715204239, 0.25314533710479736, 0.9609928131103516, 1, 45, 342.1146545410156, 1],
          "status": "success",
          "type": "view"
        }, {
          "guid": "2c6938f2-c052-4195-93d0-adc7af1cb965",
          "name": "3D Plumbing",
          "role": "3d",
          "camera": [3.6063644886016846, -184.62478637695312, 180.24473571777344, 173.09983825683594, -2.4171712398529053, -0.014680136926472187, 0.39955270290374756, 0.42952418327331543, 0.8098559379577637, 1, 45, 461.8291931152344, 1],
          "status": "success",
          "type": "view"
        }, {
          "guid": "1b3f6ae4-beb6-478c-9cfe-b83bf371141d",
          "name": "Room 53 3D Fire Protection",
          "role": "3d",
          "camera": [735.119384765625, -538.998779296875, 662.6300048828125, 98.2931900024414, 97.82740020751953, 25.80381202697754, -0.40824830532073975, 0.40824830532073975, 0.8164966106414795, 1, 45, 368.90972900390625, 1],
          "status": "success",
          "type": "view"
        }, {
          "guid": "45811cc4-79ed-421b-82b2-6c8548d1507e",
          "name": "WSHP 2-3 System View",
          "role": "3d",
          "camera": [108.588134765625, 117.7073974609375, 54.383365631103516, 102.33130645751953, 123.9642333984375, 48.12653350830078, -0.40824830532073975, 0.40824830532073975, 0.8164966106414795, 1, 45, 333.1808776855469, 1],
          "status": "success",
          "type": "view"
        }, {
          "guid": "8c1402a9-6af6-47af-af0d-2c025ca26109",
          "name": "Plumbing Isometric - Domestic Water",
          "role": "3d",
          "camera": [3.6063644886016846, -184.62478637695312, 180.24473571777344, 173.09983825683594, -2.4171712398529053, -0.014680136926472187, 0.39955270290374756, 0.42952418327331543, 0.8098559379577637, 1, 45, 461.8291931152344, 1],
          "status": "success",
          "type": "view"
        }, {
          "guid": "9dcc0f6a-fc2c-418f-8d08-c99b7afed337",
          "name": "Plumbing Isometric - Sanitary Waste",
          "role": "3d",
          "camera": [3.6063644886016846, -184.62478637695312, 180.24473571777344, 173.09983825683594, -2.4171712398529053, -0.014680136926472187, 0.39955270290374756, 0.42952418327331543, 0.8098559379577637, 1, 45, 461.8291931152344, 1],
          "status": "success",
          "type": "view"
        }, {
          "guid": "e3a2443a-7f4c-49dc-a41d-da067922ab04",
          "name": "Typical Make Up Air Isometric Detail",
          "role": "3d",
          "camera": [0.8279496431350708, 187.99771118164062, 118.81455993652344, 100.31283569335938, 88.51282501220703, 19.32967758178711, 0.40824830532073975, -0.40824830532073975, 0.8164966106414795, 1, 45, 248.74505615234375, 1],
          "status": "success",
          "type": "view"
        }, {
          "guid": "915564b9-ed83-426e-88df-002dac32363b",
          "name": "Typical Room WSHP",
          "role": "3d",
          "camera": [171.6078338623047, -3.038959264755249, 18.71452522277832, 90.31718444824219, 43.15993118286133, -21.66922950744629, -0.34472253918647766, 0.19591180980205536, 0.9180331826210022, 1, 45, 257.0640869140625, 1],
          "status": "success",
          "type": "view"
        }, {
          "guid": "12a3ef04-1364-4c23-af91-2679132e3848",
          "name": "Toilet Room",
          "role": "3d",
          "camera": [196.7369842529297, -4.305071830749512, 109.12708282470703, 98.9510269165039, 86.86759948730469, 14.070858001708984, -0.42381933331489563, 0.3951563239097595, 0.8150022625923157, 1, 45, 359.9964294433594, 1],
          "status": "success",
          "type": "view"
        }, {
          "guid": "9a34ab86-dfdf-4516-a087-b8f9775435fe",
          "name": "1st Level Slice",
          "role": "3d",
          "camera": [-76.2143325805664, -163.60708618164062, 175.46923828125, 111.73212432861328, 69.6202392578125, 11.465206146240234, 0.3013473451137543, 0.373949259519577, 0.8771269917488098, 1, 45, 313.0205993652344, 1],
          "status": "success",
          "type": "view"
        }, {
          "guid": "09effac0-27ac-4f02-b4d7-31ef18a57ef9",
          "name": "{3D}",
          "role": "3d",
          "camera": [0.8279496431350708, 187.99771118164062, 118.81455993652344, 100.31283569335938, 88.51282501220703, 19.32967758178711, 0.40824830532073975, -0.40824830532073975, 0.8164966106414795, 1, 45, 358.7159118652344, 1],
          "status": "success",
          "type": "view"
        }]
      }, {
        "guid": "f9f4721d-9304-43c4-8c07-34cbcc5e79c7",
        "role": "graphics",
        "mime": "application/autodesk-svf",
        "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZXh0cmFjdC1hdXRvZGVzay1pby0yMDE3MnVvbm5paWJkd2t1Z25ydGVvZGFjN2FpeWhwdjdrd20vcm1lX2FkdmFuY2VkX3NhbXBsZV9wcm9qZWN0Lm53ZA/output/0/0.svf",
        "type": "resource"
      }]
    }, {
      "guid": "3b7195a7-17ec-4d80-b259-4e9df165f3fb",
      "role": "Autodesk.CloudPlatform.PropertyDatabase",
      "mime": "application/autodesk-db",
      "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZXh0cmFjdC1hdXRvZGVzay1pby0yMDE3MnVvbm5paWJkd2t1Z25ydGVvZGFjN2FpeWhwdjdrd20vcm1lX2FkdmFuY2VkX3NhbXBsZV9wcm9qZWN0Lm53ZA/output/0/properties.db",
      "status": "success",
      "type": "resource"
    }]
  }, {
    "hasThumbnail": "false",
    "status": "success",
    "progress": "complete",
    "outputType": "obj",
    "children": [{
      "guid": "22519ef5-9da5-35ca-bc70-b25b45e8f8fa",
      "role": "obj",
      "modelGuid": "f9f4721d-9304-43c4-8c07-34cbcc5e79c7",
      "objectIds": [547, 924, 942, 977],
      "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZXh0cmFjdC1hdXRvZGVzay1pby0yMDE3MnVvbm5paWJkd2t1Z25ydGVvZGFjN2FpeWhwdjdrd20vcm1lX2FkdmFuY2VkX3NhbXBsZV9wcm9qZWN0Lm53ZA/output/geometry/e72fa6b3-4fc2-3c86-8424-5d0755539c0d.obj",
      "status": "success",
      "type": "resource"
    }, {
      "guid": "75401422-bb33-350a-aa10-05625504d6ca",
      "role": "obj",
      "modelGuid": "f9f4721d-9304-43c4-8c07-34cbcc5e79c7",
      "objectIds": [547, 924, 942, 977],
      "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZXh0cmFjdC1hdXRvZGVzay1pby0yMDE3MnVvbm5paWJkd2t1Z25ydGVvZGFjN2FpeWhwdjdrd20vcm1lX2FkdmFuY2VkX3NhbXBsZV9wcm9qZWN0Lm53ZA/output/geometry/e72fa6b3-4fc2-3c86-8424-5d0755539c0d.mtl",
      "status": "success",
      "type": "resource"
    }, {
      "guid": "a4b9fb43-8525-3243-bde1-72797399e342",
      "role": "obj",
      "modelGuid": "f9f4721d-9304-43c4-8c07-34cbcc5e79c7",
      "objectIds": [547, 924, 942, 977],
      "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZXh0cmFjdC1hdXRvZGVzay1pby0yMDE3MnVvbm5paWJkd2t1Z25ydGVvZGFjN2FpeWhwdjdrd20vcm1lX2FkdmFuY2VkX3NhbXBsZV9wcm9qZWN0Lm53ZA/output/geometry/e72fa6b3-4fc2-3c86-8424-5d0755539c0d.zip",
      "status": "success",
      "type": "resource"
    }, {
      "guid": "1177e7ea-7fad-34b7-a7bd-23d70e4a62a8",
      "type": "resource",
      "role": "obj",
      "modelGuid": "f9f4721d-9304-43c4-8c07-34cbcc5e79c7",
      "objectIds": [17, 19, 21, 22, 23, 24, 25, 26, 27, 83, 84, 85, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 263, 264, 265, 268, 269, 270, 302, 303, 304, 320, 321, 322, 350, 351, 352, 370, 371],
      "status": "success",
      "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZXh0cmFjdC1hdXRvZGVzay1pby0yMDE3MnVvbm5paWJkd2t1Z25ydGVvZGFjN2FpeWhwdjdrd20vcm1lX2FkdmFuY2VkX3NhbXBsZV9wcm9qZWN0Lm53ZA/output/geometry/a08e65e7-082a-3ce1-8116-ae534c9f081d.obj"
    }, {
      "guid": "61acd067-4637-3549-9bd3-cd362a4fb93b",
      "type": "resource",
      "role": "obj",
      "modelGuid": "f9f4721d-9304-43c4-8c07-34cbcc5e79c7",
      "objectIds": [17, 19, 21, 22, 23, 24, 25, 26, 27, 83, 84, 85, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 263, 264, 265, 268, 269, 270, 302, 303, 304, 320, 321, 322, 350, 351, 352, 370, 371],
      "status": "success",
      "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZXh0cmFjdC1hdXRvZGVzay1pby0yMDE3MnVvbm5paWJkd2t1Z25ydGVvZGFjN2FpeWhwdjdrd20vcm1lX2FkdmFuY2VkX3NhbXBsZV9wcm9qZWN0Lm53ZA/output/geometry/a08e65e7-082a-3ce1-8116-ae534c9f081d.mtl"
    }, {
      "guid": "6c73254c-7bbf-312a-a481-aaeebdf53de3",
      "type": "resource",
      "role": "obj",
      "modelGuid": "f9f4721d-9304-43c4-8c07-34cbcc5e79c7",
      "objectIds": [17, 19, 21, 22, 23, 24, 25, 26, 27, 83, 84, 85, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 263, 264, 265, 268, 269, 270, 302, 303, 304, 320, 321, 322, 350, 351, 352, 370, 371],
      "status": "success",
      "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZXh0cmFjdC1hdXRvZGVzay1pby0yMDE3MnVvbm5paWJkd2t1Z25ydGVvZGFjN2FpeWhwdjdrd20vcm1lX2FkdmFuY2VkX3NhbXBsZV9wcm9qZWN0Lm53ZA/output/geometry/a08e65e7-082a-3ce1-8116-ae534c9f081d.zip"
    }]
  }]
}

1 个答案:

答案 0 :(得分:0)

使用GET :urn/metadata获取模型视图列表:

{
  "data": {
    "type": "metadata",
    "metadata": [
      {
        "name": "Scene",
        "role": "3d",
        "guid": "4f981e94-8241-4eaf-b08b-cd337c6b8b1f",
      },
      {
        "name": "Sheet: A101",
        "role": "2d",
        "guid": "8e7c6bca-cfd1-290e-4b16-f3670169bb71"
      }
    ]
   }
}

然后使用GET :urn/metadata/:guid检索对象树以标识派生对象:

{
  "data": {
    "type": "objects",
    "objects": [
      {
        "objectid": 1,
        "name": "A5",
        "objects": [
          {
            "objectid": 2,
            "name": "Model",
            "objects": [
              {
                "objectid": 3,
                "name": "Bottom",
                "objects": [
                  {
                    "objectid": 4,
                    "name": "Box"
                  }
                ]
              },