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