0

I am following this tutorial to convert a .sldprt to .obj file. I wanted to accomplish this conversion using a python script, and I found a script online that accomplishes this to the point where it uploads the file to the server and begins the conversion. In step 3 of the tutorial (Verify the job is Complete), when I type the following command into the command line:

curl -X 'GET' -H 'Authorization: Bearer MYTOKEN' -v 'https://developer.api.autodesk.com/modelderivative/v2/designdata/MYURN/manifest'

I get an appropriate response (see image below):

However, doing the same thing from Python script gives me the following output:

enter image description here

My Python script is as below:

### Verify if translation is complete and get the outURN
url = BASE_URL + 'modelderivative/v2/designdata/' + urn + '/manifest'
headers = {
    'Authorization' : 'Bearer ' + ACCESS_TOKEN
}
r = requests.get(url, headers=headers)
content = eval(r.content)
print("==========================================")
print(content)
print("==========================================")

I have no idea whats the difference between the two (terminal command and the command given from python script). Can someone point out what the problem here is?

Umar Dastgir
  • 688
  • 9
  • 25
  • 2
    Don't do `eval(r.content)`. See https://stackoverflow.com/questions/1832940/why-is-using-eval-a-bad-practice – zvone May 14 '19 at 19:52

2 Answers2

1

Or better yet, listen to extraction.finished event, which notifies when a translation is done.

Augusto Goncalves
  • 8,493
  • 2
  • 17
  • 44
0

I believe I had to pause for some time after beginning the conversion to allow some time for the cloud to convert .sldprt to .stl. The solution is constantly poll the 'status' key and proceed only when the status changes from 'pending' to 'success'

Umar Dastgir
  • 688
  • 9
  • 25