File size: 1,513 Bytes
385569a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Onshape API Utilities

This module provides utilities for interacting with the Onshape API, including uploading and translating files and downloading translated files.

## Prerequisites

1. Set the following environment variables:
   - `ONSHAPE_ACCESS_KEY`
   - `ONSHAPE_SECRET_KEY`

2. Install required Python packages:
   ```bash
   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:
```python
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:
```python
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.