@@ -229,19 +229,25 @@ def add_material(self, material: Material) -> None:
229
229
230
230
@check_input_types
231
231
@ensure_design_is_active
232
- def save (self , file_location : Path | str ) -> None :
232
+ def save (self , file_location : Path | str , write_body_facets : bool = False ) -> None :
233
233
"""Save a design to disk on the active Geometry server instance.
234
234
235
235
Parameters
236
236
----------
237
237
file_location : ~pathlib.Path | str
238
238
Location on disk to save the file to.
239
+ write_body_facets : bool, default: False
240
+ Option to write body facets into the saved file. 26R1 and later.
239
241
"""
240
242
# Sanity checks on inputs
241
243
if isinstance (file_location , Path ):
242
244
file_location = str (file_location )
243
245
244
- self ._grpc_client .services .designs .save_as (filepath = file_location )
246
+ self ._grpc_client .services .designs .save_as (
247
+ filepath = file_location ,
248
+ write_body_facets = write_body_facets ,
249
+ backend_version = self ._grpc_client .backend_version ,
250
+ )
245
251
self ._grpc_client .log .debug (f"Design successfully saved at location { file_location } ." )
246
252
247
253
@protect_grpc
@@ -251,6 +257,7 @@ def download(
251
257
self ,
252
258
file_location : Path | str ,
253
259
format : DesignFileFormat = DesignFileFormat .SCDOCX ,
260
+ write_body_facets : bool = False ,
254
261
) -> None :
255
262
"""Export and download the design from the server.
256
263
@@ -260,6 +267,8 @@ def download(
260
267
Location on disk to save the file to.
261
268
format : DesignFileFormat, default: DesignFileFormat.SCDOCX
262
269
Format for the file to save to.
270
+ write_body_facets : bool, default: False
271
+ Option to write body facets into the saved file. SCDOCX only, 26R1 and later.
263
272
"""
264
273
# Sanity checks on inputs
265
274
if isinstance (file_location , str ):
@@ -275,7 +284,9 @@ def download(
275
284
if self ._modeler .client .backend_version < (25 , 2 , 0 ):
276
285
received_bytes = self .__export_and_download_legacy (format = format )
277
286
else :
278
- received_bytes = self .__export_and_download (format = format )
287
+ received_bytes = self .__export_and_download (
288
+ format = format , write_body_facets = write_body_facets
289
+ )
279
290
280
291
# Write to file
281
292
file_location .write_bytes (received_bytes )
@@ -323,7 +334,11 @@ def __export_and_download_legacy(self, format: DesignFileFormat) -> bytes:
323
334
324
335
return received_bytes
325
336
326
- def __export_and_download (self , format : DesignFileFormat ) -> bytes :
337
+ def __export_and_download (
338
+ self ,
339
+ format : DesignFileFormat ,
340
+ write_body_facets : bool = False ,
341
+ ) -> bytes :
327
342
"""Export and download the design from the server.
328
343
329
344
Parameters
@@ -351,14 +366,22 @@ def __export_and_download(self, format: DesignFileFormat) -> bytes:
351
366
DesignFileFormat .STRIDE ,
352
367
]:
353
368
try :
354
- response = self ._grpc_client .services .designs .download_export (format = format )
369
+ response = self ._grpc_client .services .designs .download_export (
370
+ format = format ,
371
+ write_body_facets = write_body_facets ,
372
+ backend_version = self ._grpc_client .backend_version ,
373
+ )
355
374
except Exception :
356
375
self ._grpc_client .log .warning (
357
376
f"Failed to download the file in { format } format."
358
377
" Attempting to stream download."
359
378
)
360
379
# Attempt to download the file via streaming
361
- response = self ._grpc_client .services .designs .stream_download_export (format = format )
380
+ response = self ._grpc_client .services .designs .stream_download_export (
381
+ format = format ,
382
+ write_body_facets = write_body_facets ,
383
+ backend_version = self ._grpc_client .backend_version ,
384
+ )
362
385
else :
363
386
self ._grpc_client .log .warning (
364
387
f"{ format } format requested is not supported. Ignoring download request."
0 commit comments