kscalelabs / onshape

K-Scale's library for programmatically interacting with OnShape
https://docs.kscale.dev/utils/onshape
MIT License
24 stars 7 forks source link

kol run hanging on 403's with Public Assemblies #103

Open i-Dyke opened 1 month ago

i-Dyke commented 1 month ago

Hi,

I and a friend have been getting stuck trying to import the online Stompy models using kol run. StompyMini StompyFull

When using the standard URLs, we are returned back a tree of 403 errors on various parts of the file. See the attached printout of the terminal.

Note that this happened both with the publicly owned models, and copied models owned by us. (It seems that even when copying to myself, it doesn't transfer ownership of the subassemblies)

I reached out to OnShape support to get some guidance on changing the ownership of subassemblies over to myself, and was returned back some insight into what is causing the 403's on the KOL side of things:

Screenshot from 2024-10-27 13-38-30 Associated Links:

getAssemblyDefinition

KOL Onshape Api.py Line100

Unfortunately, simply trying to change L100 of api.py just breaks things. I dug into this some to see if I could get a decent PR together to fix it, but it seems like this goes various different parts of the script (More in the client.py and download.py) and requires having the top-level assembly ID available to be passed by subassemblies, parts, etc. into various different calls (metadata calls seem to be the big issue per the error output .txt).

I'm not entirely sure the best way to go about this, but it might involve restructuring a lot of the Part/Subassembly/etc. classes to also include an origin DocumentId included to pass into ?linkedDocumentId=. That's just from some cursory investigation.

i-Dyke commented 1 month ago

KOLIssue103_ErrorLog403.txt

i-Dyke commented 1 month ago

Also, to clarify, the example linkedDocumentId=71f793a23ab7562fb9dec82d is the documentId for StompyFull https://cad.onshape.com/documents/71f793a23ab7562fb9dec82d/w/e879bcf272425973f9b3d8ad/e/1a95e260677a2d2d5a3b1eb3