Salome HOME
Copyright update 2020
[modules/shaper.git] / src / ConnectorAPI / Test / Test17917.py
1 # Copyright (C) 2014-2020  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 SketchAPI import *
21 from salome.shaper import model
22 from ModelAPI import *
23
24 model.begin()
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Box_1 = model.addBox(Part_1_doc, 10, 10, 2)
29 Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Box_1_1/Top")])
30 model.do()
31 Part_2 = model.addPart(partSet)
32 Part_2_doc = Part_2.document()
33 Cylinder_1 = model.addCylinder(Part_2_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10, 45)
34 Group_2 = model.addGroup(Part_2_doc, "Faces", [model.selection("FACE", "Cylinder_1_1/Face_4"), model.selection("FACE", "Cylinder_1_1/Face_2")])
35 model.do()
36 Placement_1 = model.addPlacement(partSet, [model.selection("COMPOUND", "Part_2/")], model.selection("FACE", "Part_2/Cylinder_1_1/Face_3"), model.selection("FACE", "Part_1/Box_1_1/Top"), False, True)
37 model.do()
38
39 aSession = ModelAPI_Session.get()
40 aSession.setActiveDocument(partSet, False)
41 model.do()
42
43 model.exportToGEOM(partSet)
44 model.end()
45
46 # check what is exported to GEOM
47 import salome
48 from salome.geom import geomBuilder
49
50 import os
51 import tempfile
52
53 salome.salome_init(1)
54 aComp = salome.myStudy.FindComponent("GEOM")
55 iterator = salome.myStudy.NewChildIterator(aComp)
56 aComponents = []
57 while iterator.More():
58   aComponents.append(iterator.Value())
59   iterator.Next()
60
61 assert len(aComponents) == 2
62
63 ok, group_0_1 = aComponents[0].FindSubObject(1)
64 assert ok
65 assert group_0_1.GetName() == "Group_1"
66
67 ok, group_0_2 = aComponents[0].FindSubObject(2)
68 assert not ok
69
70
71 ok, group_1_1 = aComponents[1].FindSubObject(1)
72 assert ok
73 assert group_1_1.GetName() == "Group_1"
74
75 ok, group_1_2 = aComponents[1].FindSubObject(2)
76 assert not ok