Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Getting UnicodeDecodeError calling /drawings/d/{did}/externaldata/{tid] when translating drawings?
lebenito
Member Posts: 15 ✭
When I call this call I get this UnicodeDecode Error in the Onshape Python API client.
File "C:\Users\benne\AppData\Local\pypoetry\Cache\virtualenvs\lcb-7JzeowoO-py3.9\lib\site-packages\onshape_client\oas\api_client.py", line 421, in request
return self.rest_client.GET(
File "C:\Users\benne\AppData\Local\pypoetry\Cache\virtualenvs\lcb-7JzeowoO-py3.9\lib\site-packages\onshape_client\oas\rest.py", line 324, in GET
return self.request(
File "C:\Users\benne\AppData\Local\pypoetry\Cache\virtualenvs\lcb-7JzeowoO-py3.9\lib\site-packages\onshape_client\oas\rest.py", line 264, in request
r.data = r.data.decode("utf8")
return self.rest_client.GET(
File "C:\Users\benne\AppData\Local\pypoetry\Cache\virtualenvs\lcb-7JzeowoO-py3.9\lib\site-packages\onshape_client\oas\rest.py", line 324, in GET
return self.request(
File "C:\Users\benne\AppData\Local\pypoetry\Cache\virtualenvs\lcb-7JzeowoO-py3.9\lib\site-packages\onshape_client\oas\rest.py", line 264, in request
r.data = r.data.decode("utf8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x84 in position 261: invalid start byte
For example: https://cad.onshape.com/api/documents/d/c3c64dc4cc39570a7e58f079/externaldata/63efeeac5761214485057b0a
It only happens when I translate a drawing, not a partstudio. When I manually call this in my browser where I am logged into Onshape, the PDF export functions fine, but the configuration of the drawing is not changed (still the default one).
Is something wrong with my API call? My body looks like this:
{
'formatName': 'PDF',
'storeInDocument': False,
'configuration': config,
}
The configuration works when translating the PartStudio of which the drawing is made and exporting its stl.
Different formats like dwg work, but also not with the right configuration.
Do translations work differently? And why the UnicodeDecodeError? I am not even trying to get the data of the request nor trying to print it.
0
Answers
I am wonder if this is actually possible somehow as well. To update all drawing views in a drawing to a different config using the api.
I can do this with my app Renaissance. It can duplicate a drawing and updates all of the views to a different configuration.
https://appstore.onshape.com/apps/Utilities/XRQODIZXYFFSR7TEFILBKVQH5XWN6JAQRSTFWRY=/description
This looks really great! I know it is a bit much to ask but would you share approx. what are the key end points you use to modify drawing config references after the element is duplicated? I'm guessing you are creatively combining a few different ones Because I am not immediately seeing any end points that will obviously do this. I realize you have an app and such but I am really hoping to accomplish just the drawing updating within an app we already use.
I think the endpoint your are probably missing is element references. Views/tables have a reference object, and I just update the configuration of each.
Gotcha. Thanks for that!