Uploading linked Revit models to Autodesk Forge

纵饮孤独 提交于 2019-12-13 03:45:37

问题


I've been trying to use the Post references (https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/urn-references-POST/) to set up the reference between two files in forge but although I get a message "success" as result when I try it on the forge viewer I still see the files separately even after I translate the models. Has someone been through the same issue?


回答1:


Without seeing you code it is hard to tell what is happening. Below I copied my bash script code which references/translate an obj with material and texture.

Au.obj
  +- Au.mtl
       +- Au.jpg

After upload, I got these

  • idObj="urn:adsk.objects:os.object:cyrillejcrja/Au.obj"
  • idMtl="urn:adsk.objects:os.object:cyrillejcrja/Au.mtl"
  • idJpg="urn:adsk.objects:os.object:cyrillejcrja/Au.jpg"

the code to set references, now

urn=$(xbase64encode $idObj)
job='{
    "urn": "'${idObj}'",
    "filename": "Au.obj",
    "references": [{
        "urn": "'${idMtl}'",
        "relativePath": "./Au.mtl",
        "filename": "Au.mtl",
        "references": [{
            "urn": "'${idJpg}'",
            "relativePath": "./Au.jpg"
        }]
    }]
}'
response=$(curl -H "Content-Type: application/json" \
    -H "Authorization: ${bearer}" \
    -X POST ${ForgeHost}/modelderivative/v2/designdata/${urn}/references \
    -k -s -d "${job}")

Here is got a reply like below which only means that the references are registered.

{
  "result": "success"
}

Now, I do this to translate the obj and use the references

urn=$(xbase64encode $idObj)
job='{
    "input": {
      "urn": "'${urn}'",
      "checkReferences": true
    },
    "output": {
      "formats": [
        {
          "type": "svf",
          "views": [
            "2d",
            "3d"
          ]
        }
      ]
    }
}'
response=$(curl -H "Content-Type: application/json" \
    -H  "Authorization: ${bearer}" \
    -H "x-ads-force: true" \
    -X POST ${ForgeHost}/modelderivative/v2/designdata/job \
    -k -s -d "${job}")

Note the "checkReferences": true, as documented here.

Now, I can wait the translation to complete and see the result in the Viewer.

For reference the xbase64safeencode function used above

function xbase64safeencode () { local id64=$(echo -ne $1 | base64  $wrap_arg | tr -d '=' | tr '+/' '-_'); echo $id64; }



回答2:


@Cyrille, this is my request:

curl -X 'POST' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsI' -H 'Content-Type: application/json' -v 'https://developer.api.autodesk.com/modelderivative/v2/designdata/{urn}/references' -d 
'{
  "urn": "urn:adsk.objects:os.object:bucket/non-existent.rvt",
  "filename": "",
  "references": [
    {
      "urn": "urn:adsk.objects:os.object:bucket/non-existent.rvt",
      "relativePath": "",
      "filename": ""
    }
  ]
}'

I got as result:

'{
  "result": "success"
}'

The point is I'm getting success as a result even when I do not have the specified file on the server, so I'd suggest few server-side validations, for example, when a model has been translated once we can't set as reference right so it should at least return an error. Thank you and I hope this helps.



来源:https://stackoverflow.com/questions/48648062/uploading-linked-revit-models-to-autodesk-forge

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!