Salome HOME
582c387c55f372502ff4f1ec027cf03ee95bba38
[modules/shaper.git] / src / FeaturesPlugin / Test / TestPipe_ErrorMsg.py
1 # Copyright (C) 2018-2023  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 from ModelAPI import *
21 from GeomDataAPI import *
22
23 # Get document
24 aSession = ModelAPI_Session.get()
25 aDocument = aSession.moduleDocument()
26
27 # Create a part
28 aSession.startOperation()
29 aPartFeature = aDocument.addFeature("Part")
30 aSession.finishOperation()
31 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
32 aPart = aPartResult.partDoc()
33
34 # Create a sketch with circle for pipe profile
35 aSession.startOperation()
36 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
37 origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
38 origin.setValue(0, 0, 0)
39 dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
40 dirx.setValue(1, 0, 0)
41 norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
42 norm.setValue(0, 0, 1)
43
44 # Create circle
45 aSketchCircleFeature = aSketchFeature.addFeature("SketchCircle")
46 anCircleCentr = geomDataAPI_Point2D(aSketchCircleFeature.attribute("circle_center"))
47 aCircleRadius = aSketchCircleFeature.real("circle_radius")
48 anCircleCentr.setValue(0, 0)
49 aCircleRadius.setValue(10)
50 aSession.finishOperation()
51
52 aSketchResult = aSketchFeature.firstResult()
53 aSketchShape = aSketchResult.shape()
54
55 aSession.startOperation()
56 aPipeFeature = aPart.addFeature("Pipe")
57 aPipeFeature.string("creation_method").setValue("WrongCreationMethod")
58 aPipeFeature.execute()
59 assert(aPipeFeature.error() != "")
60 aSession.finishOperation()
61
62 aSession.startOperation()
63 aBaseObjectsList = aPipeFeature.selectionList("base_objects")
64 aBaseObjectsList.append(aSketchResult, None)
65 aPipeFeature.execute()
66 assert(aPipeFeature.error() != "")
67 aSession.finishOperation()
68
69 aSession.startOperation()
70 aPathObjectSelection = aPipeFeature.selection("path_object")
71 aPathObjectSelection.selectSubShape("EDGE", "PartSet/OZ")
72 aPipeFeature.execute()
73 assert(aPipeFeature.error() != "")
74 aSession.finishOperation()
75
76 aSession.startOperation()
77 aPipeFeature.string("creation_method").setValue("binormal")
78 aPipeFeature.execute()
79 assert(aPipeFeature.error() != "")
80 aSession.finishOperation()
81
82 aSession.startOperation()
83 aPipeFeature.string("creation_method").setValue("locations")
84 aBaseObjectsList = aPipeFeature.selectionList("locations_objects")
85 aBaseObjectsList.append(None, None)
86 aPipeFeature.execute()
87 assert(aPipeFeature.error() != "")
88 aSession.finishOperation()