@@ -50,7 +50,7 @@ class ExportModes:
5050
5151def exportAssembly (
5252 assy : AssemblyProtocol ,
53- path : Path ,
53+ path : Path | str ,
5454 mode : STEPExportModeLiterals = "default" ,
5555 ** kwargs ,
5656) -> bool :
@@ -78,6 +78,9 @@ def exportAssembly(
7878 :type precision_mode: int
7979 """
8080
81+ if isinstance (path , str ):
82+ path = Path (path )
83+
8184 # Handle the extra settings for the STEP export
8285 pcurves = 1
8386 if "write_pcurves" in kwargs and not kwargs ["write_pcurves" ]:
@@ -109,7 +112,7 @@ def exportAssembly(
109112
110113def exportStepMeta (
111114 assy : AssemblyProtocol ,
112- path : Path ,
115+ path : Path | str ,
113116 write_pcurves : bool = True ,
114117 precision_mode : int = 0 ,
115118) -> bool :
@@ -129,6 +132,9 @@ def exportStepMeta(
129132 See OCCT documentation.
130133 """
131134
135+ if isinstance (path , str ):
136+ path = Path (path )
137+
132138 pcurves = 1
133139 if not write_pcurves :
134140 pcurves = 0
@@ -275,11 +281,14 @@ def _process_assembly(
275281 return status == IFSelect_ReturnStatus .IFSelect_RetDone
276282
277283
278- def exportCAF (assy : AssemblyProtocol , path : Path , binary : bool = False ) -> bool :
284+ def exportCAF (assy : AssemblyProtocol , path : Path | str , binary : bool = False ) -> bool :
279285 """
280286 Export an assembly to an XCAF xml or xbf file (internal OCCT formats).
281287 """
282288
289+ if isinstance (path , str ):
290+ path = Path (path )
291+
283292 folder = path .parent
284293 fname = path .name
285294 name = path .stem
@@ -338,11 +347,14 @@ def _vtkRenderWindow(
338347 return renderWindow
339348
340349
341- def exportVTKJS (assy : AssemblyProtocol , path : Path ):
350+ def exportVTKJS (assy : AssemblyProtocol , path : Path | str ):
342351 """
343352 Export an assembly to a zipped vtkjs. NB: .zip extensions is added to path.
344353 """
345354
355+ if isinstance (path , str ):
356+ path = Path (path )
357+
346358 renderWindow = _vtkRenderWindow (assy )
347359
348360 with TemporaryDirectory () as tmpdir :
@@ -356,14 +368,17 @@ def exportVTKJS(assy: AssemblyProtocol, path: Path):
356368
357369def exportVRML (
358370 assy : AssemblyProtocol ,
359- path : Path ,
371+ path : Path | str ,
360372 tolerance : float = 1e-3 ,
361373 angularTolerance : float = 0.1 ,
362374):
363375 """
364376 Export an assembly to a vrml file using vtk.
365377 """
366378
379+ if isinstance (path , str ):
380+ path = Path (path )
381+
367382 exporter = vtkVRMLExporter ()
368383 exporter .SetFileName (str (path ))
369384 exporter .SetRenderWindow (_vtkRenderWindow (assy , tolerance , angularTolerance ))
@@ -372,7 +387,7 @@ def exportVRML(
372387
373388def exportGLTF (
374389 assy : AssemblyProtocol ,
375- path : Path ,
390+ path : Path | str ,
376391 binary : Optional [bool ] = None ,
377392 tolerance : float = 1e-3 ,
378393 angularTolerance : float = 0.1 ,
@@ -381,6 +396,9 @@ def exportGLTF(
381396 Export an assembly to a gltf file.
382397 """
383398
399+ if isinstance (path , str ):
400+ path = Path (path )
401+
384402 # If the caller specified the binary option, respect it
385403 if binary is None :
386404 # Handle the binary option for GLTF export based on file extension
0 commit comments