Salome HOME
beee7386d6304dcb8970917c8577c6ab5a28ecf1
[modules/shaper.git] / src / PythonAddons / doc / examples / pipeNetwork.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 """Exemple de création d'un objet SHAPER tuyauterie à partir d'une description dans un fichier txte
4
5 Copyright 2021 EDF
6 """
7
8 __revision__ = "V02.01"
9
10 #=================================================================================
11 # theFile = fichier texte de la description du réseau
12 theFile = "/home/D68518/pipeNetwork_ligne.txt"
13 #=================================================================================
14
15 import salome
16 salome.standalone()
17 salome.salome_init()
18
19 from ModelAPI import *
20
21 aSession = ModelAPI_Session.get()
22
23 # Création de la part pour accueillir le réseau
24 aSession.startOperation("Create part for pipe network")
25 aPartFeature = aSession.moduleDocument().addFeature("Part")
26 aSession.finishOperation()
27 aPart = aSession.activeDocument()
28
29 # Importation et traitement du fichier
30 aSession.startOperation("Import file")
31 aFeatureKind = "pipeNetwork"
32 anImportFeature = aPart.addFeature(aFeatureKind)
33 aFieldName = "file_path"
34 aFile = anImportFeature.string(aFieldName)
35 aFile.setValue(theFile)
36 aSession.finishOperation()
37
38 if salome.sg.hasDesktop():
39   salome.sg.updateObjBrowser()