1 # Copyright (C) 2014-2016 CEA/DEN, EDF R&D
3 # File: UnitTestAxis.py
5 # Author: Clarisse Genrault (CEA)
9 Unit Test of ConstructionPlugin_Axis class
12 static const std::string CONSTRUCTION_AXIS_KIND("Axis");
13 static const std::string METHOD_ATTR("CreationMethod");
14 static const std::string POINT_ATTR_FIRST("FirstPoint");
15 static const std::string POINT_ATTR_SECOND("SecondPoint");
16 static const std::string CYLINDRICAL_FACE_ATTR("CylindricalFace");
17 static const std::string X_ATTR("X");
18 static const std::string Y_ATTR("Y");
19 static const std::string Z_ATTR("Z");
22 data()->addAttribute(ConstructionPlugin_Axis::METHOD(), ModelAPI_AttributeString::typeId());
24 data()->addAttribute(ConstructionPlugin_Axis::POINT_FIRST(), ModelAPI_AttributeSelection::typeId());
25 data()->addAttribute(ConstructionPlugin_Axis::POINT_SECOND(), ModelAPI_AttributeSelection::typeId());
27 data()->addAttribute(ConstructionPlugin_Axis::CYLINDRICAL_FACE(), ModelAPI_AttributeSelection::typeId());
29 data()->addAttribute(ConstructionPlugin_Axis::X(), ModelAPI_AttributeDouble::typeId());
30 data()->addAttribute(ConstructionPlugin_Axis::Y(), ModelAPI_AttributeDouble::typeId());
31 data()->addAttribute(ConstructionPlugin_Axis::Z(), ModelAPI_AttributeDouble::typeId());
36 #=========================================================================
37 # Initialization of the test
38 #=========================================================================
39 from ModelAPI import *
40 from GeomDataAPI import *
41 from GeomAlgoAPI import *
45 __updated__ = "2016-01-04"
47 aSession = ModelAPI_Session.get()
48 aDocument = aSession.moduleDocument()
49 # Create a part for creation of a box
50 aSession.startOperation()
51 aPartFeature = aDocument.addFeature("Part")
52 aSession.finishOperation()
53 assert (len(aPartFeature.results()) == 1)
55 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
56 aPart = aPartResult.partDoc()
57 #=========================================================================
58 # Creation of an Axis by coordinates
59 #=========================================================================
60 aSession.startOperation()
61 anAxisByDimensions = aPart.addFeature("Axis")
62 anAxisByDimensions.string("CreationMethod").setValue("AxisByDimensionsCase")
63 anAxisByDimensions.real("DX").setValue(2.5)
64 anAxisByDimensions.real("DY").setValue(3.2)
65 anAxisByDimensions.real("DZ").setValue(1.4)
66 anAxisByDimensions.execute()
69 assert(len(anAxisByDimensions.results()) > 0)
70 anAxisByDimensions = modelAPI_ResultConstruction(anAxisByDimensions.firstResult())
71 assert(anAxisByDimensions is not None)
73 aSession.finishOperation()
74 #=========================================================================
76 #=========================================================================
78 from salome.shaper import model
79 assert(model.checkPythonDump())