Salome HOME
a8bd057618b390629cf6d69983c5173f11af4493
[modules/shaper.git] / src / PythonAPI / model / services / __init__.py
1 # Copyright (C) 2016-2019  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 """Package for services for the Parametric Geometry API of the Modeler.
20 """
21
22 from ModelHighAPI import moduleDocument, activeDocument
23 from ModelHighAPI import defaultPlane, standardPlane
24 from ModelHighAPI import begin, end
25 from ModelHighAPI import apply as do
26 from ModelHighAPI import updateFeatures
27 from ModelHighAPI import undo, redo
28 from ModelHighAPI import reset
29 from ModelHighAPI import addFolder, removeFolder
30 from ModelHighAPI import ModelHighAPI_Selection as selection
31 from ModelHighAPI import checkPythonDump as checkPythonDump
32 from ModelAPI import findPartFeature
33
34 # a method used for the python dump of the SHAPER STUDY
35 def publishToShaperStudy():
36   begin()
37   activeDocument().addFeature("PublishToStudy")
38   end()
39
40 # returns unique identifier of the feature : id of part it belongs to + ":" + id of feature
41 def featureStringId(theFeature):
42   aRoot = moduleDocument()
43   aCurrent = theFeature.feature().document()
44   if aRoot and aCurrent:
45     return str(findPartFeature(aRoot, aCurrent).data().featureId()) + ":" + str(theFeature.feature().data().featureId())
46   return ""