A newer version of the Gradio SDK is available:
5.41.1
Onshape API Utilities
This module provides utilities for interacting with the Onshape API, including uploading and translating files and downloading translated files.
Prerequisites
Set the following environment variables:
ONSHAPE_ACCESS_KEY
ONSHAPE_SECRET_KEY
Install required Python packages:
pip install requests loguru
Modules
onshape_base.py
Provides the OnshapeBase
class for shared functionality like authentication and base URL construction.
onshape_translation.py
Handles file upload and translation. Supports any file type and export format.
Example Usage:
from onshape_translation import OnshapeTranslation
did = "your_document_id"
wid = "your_workspace_id"
file_path = "path_to_your_file"
format_name = "desired_format" # e.g., "STEP", "IGES", etc.
translator = OnshapeTranslation(did, wid, file_path, format_name)
translator.upload_and_translate()
onshape_download.py
Handles downloading translated files.
Example Usage:
from onshape_download import OnshapeDownload
did = "your_document_id"
wid = "your_workspace_id"
eid = "your_element_id" # you can find it in `resultElementIds` when `requestState` of `TranslationStatusResponse` is `DONE`
output_file = "output_file_name"
downloader = OnshapeDownload(did, wid, eid, output_file)
downloader.download()
Logging
This module uses loguru
for logging. Logs will display detailed information about the operations performed.