21
21
# SOFTWARE.
22
22
"""Test design import."""
23
23
24
+ from pathlib import Path
25
+
24
26
import numpy as np
25
27
from pint import Quantity
26
28
import pytest
33
35
from ansys .geometry .core .misc import UNITS
34
36
from ansys .geometry .core .sketch import Sketch
35
37
36
- from .conftest import skip_if_linux
38
+ from .conftest import FILES_DIR , IMPORT_FILES_DIR , skip_if_linux
37
39
38
40
39
41
def _checker_method (comp : Component , comp_ref : Component , precise_check : bool = True ) -> None :
@@ -135,7 +137,7 @@ def test_design_import_with_surfaces_issue834(modeler: Modeler):
135
137
skip_if_linux (modeler , test_design_import_with_surfaces_issue834 .__name__ , "open_file" )
136
138
137
139
# Open the design
138
- design = modeler .open_file ("./tests/integration/files/ DuplicateFacesDesignBefore.scdocx" )
140
+ design = modeler .open_file (Path ( FILES_DIR , " DuplicateFacesDesignBefore.scdocx") )
139
141
140
142
# Check that there are two bodies
141
143
assert len (design .bodies ) == 2
@@ -207,39 +209,39 @@ def test_open_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory):
207
209
# file = tmp_path_factory.mktemp("test_design_import") / "two_cars.igs"
208
210
# design.download(file, DesignFileFormat.IGES)
209
211
# design2 = modeler.open_file(file)
210
- # design3 = modeler.open_file("./tests/integration/files/import/ twoCars.igs")
212
+ # design3 = modeler.open_file(Path(IMPORT_FILES_DIR, " twoCars.igs")
211
213
# _checker_method(design2, design3, False)
212
214
213
215
# STEP
214
216
file = tmp_path_factory .mktemp ("test_design_import" ) / "two_cars.step"
215
217
design .download (file , DesignFileFormat .STEP )
216
218
design2 = modeler .open_file (file )
217
- design3 = modeler .open_file ("./tests/integration/files/import/ twoCars.stp" )
219
+ design3 = modeler .open_file (Path ( IMPORT_FILES_DIR , " twoCars.stp") )
218
220
_checker_method (design2 , design3 , False )
219
221
220
222
# Catia
221
- design2 = modeler .open_file ("./tests/integration/files/import/ catia_car/car.CATProduct" )
223
+ design2 = modeler .open_file (Path ( IMPORT_FILES_DIR , " catia_car/car.CATProduct") )
222
224
_checker_method (design , design2 , False )
223
225
224
226
# Rhino
225
- design2 = modeler .open_file ("./tests/integration/files/import/ box.3dm" )
227
+ design2 = modeler .open_file (Path ( IMPORT_FILES_DIR , " box.3dm") )
226
228
assert len (design2 .components ) == 1
227
229
assert len (design2 .components [0 ].bodies ) == 1
228
230
229
231
# Stride
230
- design2 = modeler .open_file ("./tests/integration/files/import/ sample_box.project" )
232
+ design2 = modeler .open_file (Path ( IMPORT_FILES_DIR , " sample_box.project") )
231
233
assert len (design2 .bodies ) == 1
232
234
233
235
# SolidWorks
234
- design2 = modeler .open_file ("./tests/integration/files/import/ partColor.SLDPRT" )
236
+ design2 = modeler .open_file (Path ( IMPORT_FILES_DIR , " partColor.SLDPRT") )
235
237
assert len (design2 .components [0 ].bodies ) == 1
236
238
237
239
# .par
238
- design2 = modeler .open_file ("./tests/integration/files/import/ Tank_Bottom.par" )
240
+ design2 = modeler .open_file (Path ( IMPORT_FILES_DIR , " Tank_Bottom.par") )
239
241
assert len (design2 .bodies ) == 1
240
242
241
243
# .prt
242
- design2 = modeler .open_file ("./tests/integration/files/import/ disk1.prt" )
244
+ design2 = modeler .open_file (Path ( IMPORT_FILES_DIR , " disk1.prt") )
243
245
assert len (design2 .bodies ) == 1
244
246
245
247
@@ -257,7 +259,7 @@ def test_design_insert(modeler: Modeler):
257
259
comp .extrude_sketch ("Body_Cylinder" , sketch , 5 )
258
260
259
261
# Insert a different file
260
- design .insert_file ("./tests/integration/files/ DuplicateFacesDesignBefore.scdocx" )
262
+ design .insert_file (Path ( FILES_DIR , " DuplicateFacesDesignBefore.scdocx") )
261
263
262
264
# Check that there are two components
263
265
assert len (design .components ) == 2
@@ -280,7 +282,7 @@ def test_design_insert_with_import(modeler: Modeler):
280
282
comp .extrude_sketch ("Body_Cylinder" , sketch , 5 )
281
283
282
284
# Import and insert a different file
283
- design .insert_file ("./tests/integration/files/import/ catia_car/Wheel1.CATPart" )
285
+ design .insert_file (Path ( IMPORT_FILES_DIR , " catia_car/Wheel1.CATPart") )
284
286
285
287
# Check that there are two components
286
288
assert len (design .components ) == 2
0 commit comments