3 #################################
4 Using SALOME GUI python interface
5 #################################
8 The extended salome.py Python module provides **sg** variable, which gives access to some GUI functions.
10 **Note**, that this variable is not available if you use salome.py
11 Python module outside of the GUI desktop, i.e. without the embedded Python
12 console (since SWIG library is linked directly to the GUI library).
16 .. code-block:: python
19 # update Object browser contents
20 salome.sg.updateObjBrowser(True)
22 # get the active study ID
23 studyId = salome.sg.getActiveStudyId()
25 # get the active study name
26 studyName = salome.sg.getActiveStudyName()
28 # get the selected objects
29 selCount = salome.sg.SelectedCount() # the number of selected items
30 for i in range(selCount):
31 print salome.sg.getSelected(i) # print the entry ID of i-th selected item
33 .. code-block:: python
36 # get the list of IDs of all selected objects
37 selected = salome.sg.getAllSelected()
39 # add an object to the selection
40 salome.sg.AddIObject("0:1:1:1") # "0:1:1:1" is an object ID
42 # remove an object from the selection (make it unselected)
43 salome.sg.RemoveIObject("0:1:1:1") # "0:1:1:1" is an object ID
45 # clear the selection (set all objects unselected)
46 salome.sg.ClearIObjects()
48 # display an object in the current view (if possible)
49 salome.sg.Display("0:1:1:1") # "0:1:1:1" is an object ID
50 salome.sg.UpdateView() # update view
52 # erase an object from the current view
53 salome.sg.Erase("0:1:1:1") # "0:1:1:1" is an object ID
54 salome.sg.UpdateView() # update view
56 # display all objects in the current view (if possible)
57 salome.sg.DisplayAll()
58 salome.sg.UpdateView() # update view
60 # erase all objects from the current view
62 salome.sg.UpdateView() # update view
64 # set top, bottom, front, rear, left, right view
65 salome.sg.ViewTop() # top view
66 salome.sg.ViewBottom() # bottom view
67 salome.sg.ViewFront() # front view
68 salome.sg.ViewTop() # back view
69 salome.sg.ViewLeft() # left view
70 salome.sg.ViewRight() # right view
72 # reset the current view
75 # get the component symbolic name by its user name
76 compName = salome.sg.getComponentName("Geometry") # compoName = "GEOM"
78 # get the component user name by its symbolic name
79 compName = salome.sg.getComponentUserName("SMESH") # compoName = "Mesh"