Skip to content

Commit 30ad848

Browse files
Moved .stl generation to temp dir
1 parent 624b97e commit 30ad848

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

examples/ansys/Readme.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ Clone this repository, navigate to the `examples/ansys/spaceclaim_tess` director
3333
```bash
3434
tesseract-runtime serve --port <port_number_1>
3535
```
36-
Note that we dont build a Tesseract image for SpaceClaim in this example. This is because SpaceClaim cannot be installed in a containerized environment. You can test it using:
36+
Note that we dont build a Tesseract image for SpaceClaim in this example. This is because SpaceClaim cannot be installed in a containerized environment. You can test it using git bash and your specific Spaceclaim.exe Path:
37+
38+
```bash
39+
curl -d '{"inputs":{"differentiable_bar_parameters": [[0, 3.14], [0.39, 3.53], [0.79, 3.93], [1.18, 4.32], [1.57, 4.71], [1.96, 5.11], [2.36, 5.50], [2.75, 5.89]], "differentiable_plane_parameters": [200, 600], "non_differentiable_parameters": [800, 100], "string_parameters":["F:\\Ansys installations\\ANSYS Inc\\v241\\scdm\\SpaceClaim.exe", "geometry_generation.scscript"]}}' -H "Content-Type: application/json" http://127.0.0.1:8000/apply
40+
```
41+
42+
or the equivalent on powershell:
3743

3844
```powershell
3945
Invoke-RestMethod -Uri "http://127.0.0.1:8000/apply" -Method Post -Body (

examples/ansys/spaceclaim_tess/tesseract_api.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,16 @@ def build_geometry(
120120
# and instead use the unique run directory created everytime the
121121
# tesseract is run (so there is history).
122122
with TemporaryDirectory() as temp_dir:
123-
prepped_file_path, output_file = _prep_scscript(
123+
prepped_script_path, output_file = _prep_scscript(
124124
temp_dir,
125125
spaceclaim_script,
126126
differentiable_bar_parameters,
127127
differentiable_plane_parameters,
128128
non_differentiable_parameters,
129129
)
130-
run_spaceclaim(spaceclaim_exe, prepped_file_path)
130+
run_spaceclaim(spaceclaim_exe, prepped_script_path)
131131

132-
mesh = trimesh.load(output_file)
132+
mesh = trimesh.load(output_file)
133133

134134
return mesh
135135

@@ -147,12 +147,10 @@ def _prep_scscript(
147147
"""
148148
# Define output file name and location
149149
# TODO: Same as before: can we output grid_fin.stl in the tesseract
150-
# unique run directory instead of cwd?
151-
cwd = os.getcwd()
152-
output_file = os.path.join(cwd, "grid_fin.stl")
153-
154-
prepped_file_path = os.path.join(temp_dir, os.path.basename(spaceclaim_script))
155-
shutil.copy(spaceclaim_script, prepped_file_path)
150+
# unique run directory instead of temp dir to keep history?
151+
output_file = os.path.join(temp_dir, "grid_fin.stl")
152+
prepped_script_path = os.path.join(temp_dir, os.path.basename(spaceclaim_script))
153+
shutil.copy(spaceclaim_script, prepped_script_path)
156154

157155
# Define dict used to input params to .scscript
158156
keyvalues = {}
@@ -168,9 +166,9 @@ def _prep_scscript(
168166
keyvalues[f"__params__.s{i + 1}"] = str(differentiable_bar_parameters[i][0])
169167
keyvalues[f"__params__.e{i + 1}"] = str(differentiable_bar_parameters[i][1])
170168

171-
_find_and_replace_keys_in_archive(prepped_file_path, keyvalues)
169+
_find_and_replace_keys_in_archive(prepped_script_path, keyvalues)
172170

173-
return [prepped_file_path, output_file]
171+
return [prepped_script_path, output_file]
174172

175173

176174
def _safereplace(filedata: str, key: str, value: str) -> str:

0 commit comments

Comments
 (0)