1
1
# Setup paths for module imports
2
2
from _unittest .conftest import BasisTest , pyaedt_unittest_check_desktop_error
3
+ from pyaedt .modeler .Modeler import FaceCoordinateSystem
3
4
4
5
try :
5
6
import pytest # noqa: F401
@@ -271,7 +272,7 @@ def test_39_create_coaxial(self):
271
272
assert isinstance (coax [1 ].id , int )
272
273
assert isinstance (coax [2 ].id , int )
273
274
274
- def test_40_create_coordinate (self ):
275
+ def test_40_create_coordinate_system (self ):
275
276
cs = self .aedtapp .modeler .create_coordinate_system ()
276
277
assert cs
277
278
assert cs .update ()
@@ -287,13 +288,83 @@ def test_40_create_coordinate(self):
287
288
assert cs .change_cs_mode (0 )
288
289
assert cs .delete ()
289
290
291
+ def test_40a_create_face_coordinate_system (self ):
292
+ box = self .aedtapp .modeler .create_box ([0 , 0 , 0 ], [2 , 2 , 2 ])
293
+ face = box .faces [0 ]
294
+ fcs = self .aedtapp .modeler .create_face_coordinate_system (face , face .edges [0 ], face .edges [1 ])
295
+ assert fcs
296
+ assert fcs .face_id == face .id
297
+ assert fcs .update ()
298
+ assert fcs .delete ()
299
+ fcs2 = self .aedtapp .modeler .create_face_coordinate_system (face , face , face .edges [1 ].vertices [0 ])
300
+ assert fcs2
301
+ assert fcs2 .delete ()
302
+ fcs2 = self .aedtapp .modeler .create_face_coordinate_system (
303
+ face , face .edges [0 ].vertices [0 ], face .edges [1 ].vertices [0 ]
304
+ )
305
+ assert fcs2
306
+ assert fcs2 .delete ()
307
+ fcs3 = self .aedtapp .modeler .create_face_coordinate_system (
308
+ face , face .edges [1 ].vertices [1 ], face .edges [1 ].vertices [0 ]
309
+ )
310
+ assert fcs3
311
+ assert fcs3 .delete ()
312
+ fcs4 = self .aedtapp .modeler .create_face_coordinate_system (face , face .edges [2 ], face .edges [3 ], name = "test" )
313
+ assert fcs4
314
+ assert fcs4 .name == "test"
315
+ assert fcs4 .delete ()
316
+ fcs5 = self .aedtapp .modeler .create_face_coordinate_system (face , face .edges [2 ], face .edges [3 ], axis = "Y" )
317
+ assert fcs5
318
+ assert fcs5 .props ["WhichAxis" ] == "Y"
319
+ assert fcs5 .delete ()
320
+ fcs6 = self .aedtapp .modeler .create_face_coordinate_system (face , face .edges [2 ], face .edges [3 ], rotation = 14.3 )
321
+ assert fcs6
322
+ assert fcs6 .props ["ZRotationAngle" ] == "14.3deg"
323
+ assert fcs6 .delete ()
324
+ fcs7 = self .aedtapp .modeler .create_face_coordinate_system (face , face .edges [2 ], face .edges [3 ], offset = [0.2 , 0.3 ])
325
+ assert fcs7
326
+ assert fcs7 .props ["XOffset" ] == "0.2" + self .aedtapp .modeler .model_units
327
+ assert fcs7 .props ["YOffset" ] == "0.3" + self .aedtapp .modeler .model_units
328
+ assert fcs7 .delete ()
329
+ fcs8 = self .aedtapp .modeler .create_face_coordinate_system (face .id , face .edges [0 ].id , face .edges [1 ].id )
330
+ assert fcs8
331
+ assert fcs8 .delete ()
332
+ fcs9 = self .aedtapp .modeler .create_face_coordinate_system (face .id , face .edges [0 ].vertices [0 ].id , face .id )
333
+ assert fcs9
334
+ assert fcs9 .delete ()
335
+ fcs10 = self .aedtapp .modeler .create_face_coordinate_system (
336
+ face , face .edges [2 ], face .edges [3 ], always_move_to_end = False
337
+ )
338
+ assert fcs10
339
+ assert fcs10 .props ["MoveToEnd" ] is False
340
+ assert fcs10 .delete ()
341
+ fcs = FaceCoordinateSystem (self .aedtapp .modeler )
342
+ assert fcs ._part_name is None
343
+ assert fcs ._get_type_from_id (box .id ) == "3dObject"
344
+ assert fcs ._get_type_from_id (face .id ) == "Face"
345
+ assert fcs ._get_type_from_id (face .edges [0 ].id ) == "Edge"
346
+ assert fcs ._get_type_from_id (face .edges [0 ].vertices [0 ].id ) == "Vertex"
347
+ assert fcs ._get_type_from_object (box ) == "3dObject"
348
+ assert fcs ._get_type_from_object (face ) == "Face"
349
+ assert fcs ._get_type_from_object (face .edges [0 ]) == "Edge"
350
+ assert fcs ._get_type_from_object (face .edges [0 ].vertices [0 ]) == "Vertex"
351
+
290
352
def test_41_rename_coordinate (self ):
291
353
cs = self .aedtapp .modeler .create_coordinate_system (name = "oldname" )
292
354
assert cs .name == "oldname"
293
355
assert cs .rename ("newname" )
294
356
assert cs .name == "newname"
295
357
assert cs .delete ()
296
358
359
+ def test_41a_rename_face_coordinate (self ):
360
+ box = self .aedtapp .modeler .create_box ([0 , 0 , 0 ], [2 , 2 , 2 ])
361
+ face = box .faces [0 ]
362
+ fcs = self .aedtapp .modeler .create_face_coordinate_system (face , face .edges [0 ], face .edges [1 ], name = "oldname" )
363
+ assert fcs .name == "oldname"
364
+ assert fcs .rename ("newname" )
365
+ assert fcs .name == "newname"
366
+ assert fcs .delete ()
367
+
297
368
def test_42A_update_coordinate_system (self ):
298
369
for cs in self .aedtapp .modeler .coordinate_systems :
299
370
cs .delete ()
@@ -310,11 +381,36 @@ def test_42A_update_coordinate_system(self):
310
381
cs2 .props ["Theta" ] = 30
311
382
assert cs2 .update ()
312
383
cs2 .ref_cs = "Global"
313
- cs2 .update ()
384
+ assert cs2 .update ()
314
385
assert tuple (self .aedtapp .modeler .oeditor .GetCoordinateSystems ()) == ("Global" , "CS1" , "CS2" )
315
386
assert len (self .aedtapp .modeler .coordinate_systems ) == 2
316
387
assert cs2 .delete ()
317
388
389
+ def test_42A_update_face_coordinate_system (self ):
390
+ for cs in self .aedtapp .modeler .coordinate_systems :
391
+ cs .delete ()
392
+ box = self .aedtapp .modeler .create_box ([0 , 0 , 0 ], [2 , 2 , 2 ])
393
+ face = box .faces [0 ]
394
+ fcs = self .aedtapp .modeler .create_face_coordinate_system (face , face .edges [0 ], face .edges [1 ], name = "FCS1" )
395
+ assert fcs
396
+ fcs .props ["XOffset" ] = "0.2mm"
397
+ fcs .props ["YOffset" ] = "0.3mm"
398
+ assert fcs .props ["XOffset" ] == "0.2mm"
399
+ assert fcs .props ["YOffset" ] == "0.3mm"
400
+ assert fcs .update ()
401
+ fcs .props ["ZRotationAngle" ] = "14.3deg"
402
+ assert fcs .update ()
403
+ assert fcs .props ["ZRotationAngle" ] == "14.3deg"
404
+ fcs .props ["WhichAxis" ] = "Y"
405
+ assert fcs .update ()
406
+ assert fcs .props ["WhichAxis" ] == "Y"
407
+ fcs .props ["MoveToEnd" ] = False
408
+ assert fcs .update ()
409
+ assert fcs .props ["MoveToEnd" ] is False
410
+ assert tuple (self .aedtapp .modeler .oeditor .GetCoordinateSystems ()) == ("Global" , "FCS1" )
411
+ assert len (self .aedtapp .modeler .coordinate_systems ) == 1
412
+ assert fcs .delete ()
413
+
318
414
def test_42B_set_as_working_cs (self ):
319
415
for cs in self .aedtapp .modeler .coordinate_systems :
320
416
cs .delete ()
@@ -323,10 +419,31 @@ def test_42B_set_as_working_cs(self):
323
419
assert cs1 .set_as_working_cs ()
324
420
assert cs2 .set_as_working_cs ()
325
421
422
+ def test_42C_set_as_working_face_cs (self ):
423
+ for cs in self .aedtapp .modeler .coordinate_systems :
424
+ cs .delete ()
425
+ box = self .aedtapp .modeler .create_box ([0 , 0 , 0 ], [2 , 2 , 2 ])
426
+ face = box .faces [0 ]
427
+ fcs1 = self .aedtapp .modeler .create_face_coordinate_system (face , face .edges [0 ], face .edges [1 ])
428
+ fcs2 = self .aedtapp .modeler .create_face_coordinate_system (face , face , face .edges [1 ])
429
+ assert fcs1 .set_as_working_cs ()
430
+ assert fcs2 .set_as_working_cs ()
431
+
326
432
def test_43_set_working_coordinate_system (self ):
327
433
cs1 = self .aedtapp .modeler .create_coordinate_system (name = "new1" )
328
- self .aedtapp .modeler .set_working_coordinate_system ("Global" )
329
- self .aedtapp .modeler .set_working_coordinate_system ("new1" )
434
+ assert self .aedtapp .modeler .set_working_coordinate_system ("Global" )
435
+ assert self .aedtapp .modeler .set_working_coordinate_system ("new1" )
436
+ assert self .aedtapp .modeler .set_working_coordinate_system ("Global" )
437
+ assert self .aedtapp .modeler .set_working_coordinate_system (cs1 )
438
+
439
+ def test_43_set_working_face_coordinate_system (self ):
440
+ box = self .aedtapp .modeler .create_box ([0 , 0 , 0 ], [2 , 2 , 2 ])
441
+ face = box .faces [0 ]
442
+ fcs = self .aedtapp .modeler .create_face_coordinate_system (face , face , face .edges [1 ], name = "new2" )
443
+ assert self .aedtapp .modeler .set_working_coordinate_system ("Global" )
444
+ assert self .aedtapp .modeler .set_working_coordinate_system ("new2" )
445
+ assert self .aedtapp .modeler .set_working_coordinate_system ("Global" )
446
+ assert self .aedtapp .modeler .set_working_coordinate_system (fcs )
330
447
331
448
def test_44_sweep_around_axis (self ):
332
449
rect1 = self .aedtapp .modeler .primitives .create_rectangle (
0 commit comments