From CAELinuxWiki
Revision as of 03:28, 23 October 2010 by JMB (Talk | contribs) (Initial draft)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Salome Python Coding: Where to Start?

Under Construction !!!

By Reading

1. Look at some code that is already out there on your PC! Click on the Help button of Salome's specific module (say Help -> Geometry Module -> User's Guide) and then in the browser (after enabling scripts, if they are disabled) Click on the little "+" beside "Introduction to Geometry" then the little "+" beside "Python Interface"; then the little "+" beside "Examples, generated from GEOM_SWIG test scripts" and finally "" or

2. Use the GUI to create a study: Geometry and Mesh using available tutorials on the Salome, CAELinux websites.


3. Dump the study so that a *.py, a * and a * are created, which you can become the basis of your python code.

4. Learn how to take these python scripts and covert them to your own running scripts. There are YouTube videos that teach you how to do that. Search words "Salome Tutorial".

5. Read the docs at


The docs in your PC are under: GEOM Module

 galeon file:///opt/salome_5.1.4/DOCUMENTATION_SRC_5.1.4/GEOM/tui/GEOM/index.html
 galeon file:///opt/salome_5.1.4/DOCUMENTATION_SRC_5.1.4/GEOM/gui/GEOM/index.html

MESH Module:

 galeon file:///opt/salome_5.1.4/DOCUMENTATION_SRC_5.1.4/SMESH/tui/SMESH/index.html
 galeon file:///opt/salome_5.1.4/DOCUMENTATION_SRC_5.1.4/SMESH/gui/SMESH/index.html


By Probing

As a shotgun approach to having all the modules available to you, in the Salome command console type the following:

import GEOM, geompy
import salome, SALOMEDS
import sys, math, time, os
import VISU, visu_gui

Then type:


You will get a long list such as the one below. The objects shown here will differ from your list, because it is specific to the study I captured it from. But some objects will be common such as GEOM, geompy, salome, SALOMEDS, sys, math, time, os, VISU and visu_gui, since you imported them earlier. Many others such as Compound_1_Faces, DefParabola, Depth, ... Z-Axis, Z_Master, etc. came from the script file that I used in my study.

['Box_1', 'Compound_1', 'Compound_1_Faces', 'DefParabola', 'Depth', 'Extrusion_1', 'Face_1', 'FileName', 'GEOM', 'Height', 'Help',
'Length', 'Line', 'LineList', 'MEFISTO_2D_1', 'Max_Size_1', 'Mesh_1', 'NMax', 'Origin', 'PT_Fixed', 'PT_Load', 'PathName', 
'PlaneDim', 'Regular_1D_1', 'SALOMEDS', 'SMESH', 'SalomeDoc', 'SaveStudy', 'Start', 'StdMeshers', 'Tetrahedron_Netgen', 'VISU', 
'Vertex1', 'Vertex2', 'Vertex_Final', 'Vertex_Initial', 'Width', 'Wire_1', 'X_Axis', 'Y_Axis', 'Z_Axis', 'Z_Fixed', 'Z_Load', 
'Z_Master', '__builtins__', '__doc__', '__name__', 'aColor', 'aCriterion', 'aFace', 'aPoint', 'geompy', 'i', 'index', 'math', 
'myCellEntity', 'myMeshName', 'myNodeEntity', 'myView', 'myViewManager', 'myVisu', 'name', 'os', 'salome', 'smesh', 'smeshDC',
'sys', 'time', 'visu_gui', 'x']

Since the list above shows 'Compound_1', 'Mesh_1', etc. as well as all other modules and objects in the study. Let us try getting information about each one and the objects/methods available in each. If you did not create a compound geometry object you may not have an object called 'Compound_1'; just try it with any other geometric object that you did create (say 'Box_1', 'Sphere_1', etc.)