interactive Python Console ?
interactive Python Console ?Posted by givlio at April 13. 2012
I have a quite good knowledge on grafical commands of salome but I m not able to understand how the Python Console works.
Is it interactive?
For example , could I get a vertex coordinates typing the command directly in the console when the study is yet loaded or not?
I ask this because sometime we need to perform some simple math calculation with geometrical coordinates that could be implemented directly launching the script when the model is yet loaded.
Is otherwise possible to implement some new graphical commands directly in GEOM module defining the related math geometric formulas ?
Re: interactive Python Console ?Posted by Saint Michael at April 13. 2012
> could I get a vertex coordinates typing the command directly in the console when the study is yet loaded or not?
>>> import salome, geompy
>>> studyObject = salome.myStudy.FindObjectID('0:1:1:1')
>>> vertex = studyObject.GetObject()
>>> geompy.PointCoordinates( vertex )
Thanks for fast reply,
I had to study a bit Python to make it work properly, I made in this way:
# Define myStudy (the current one if I am working in the GUI)
study = salome.myStudy
#a is what I am searching for
a = 'Vertex_1' is what I was looking for
sobject = study.FindObject( a )
# Transform the 'sobject' in 'object' (a geometrical instance I suppose)
vert = sobject.GetObject()
# Now I get the Point Coordinates from 'vert1' and put values in a Tuple
v_coord = geompy.PointCoordinates(vert)
### END CODE##
Now I would like to ask an input from the user to pass the script the value to search.
I thought tha raw_input() command could fit for this task but I receive an EOF Error , when the raw_input() works fine out from Salome (in a standard interactive Python shell):
is there a known bug for it? and is there any workaround to get a value from the user (maybe with the graphical interface directly)?
Re: interactive Python Console ?Posted by Saint Michael at May 02. 2012
A cheap solution is to use Notebook where the user can enter named variables. A 'nice' solution is to add a plug-in to SALOME (for docs see http://docs.salome-platform.org/salome_6_4_0/gui/GUI/using_pluginsmanager.html, for demo see GUI_SRC/src/SalomeApp/pluginsdemo)
Notebook?? I didnt find anything about it
Thanks for links, I tryed to implement my own script and it works directly from Tools->Plugin... but In the example there is not the code for a minimal graphical interface to pass some values to the python module (I see is written in PyQT), any hint about writing it or when I could find the other module called 'Tube Mesh from parameters' shown in
>>> for demo see GUI_SRC/src/SalomeApp/pluginsdemo)
I didnt find anything named in this way , is it a web link or a link to the internal path of Salome installation.
Re: interactive Python Console ?Posted by Saint Michael at May 03. 2012
The user gets access to Notebook via menu File / Notebook...
GUI_SRC/src/SalomeApp/pluginsdemo is a path within SALOME sources, you can find same files in GUI/share/salome/plugins/gui/demo/ of SALOME installation
Re: interactive Python Console ?Posted by givlio at May 03. 2012
Thanks a lot ,
It works fine with the GUI also passing strings and not only values and boolean values as in Notebook.
Another thing, is there any example implementing the direct mouse selection of an item? any documentation ?
Thanks a lot for your support
Re: interactive Python Console ?Posted by Saint Michael at May 04. 2012
See sample module ATOMGEN. Look for "selection" in ATOMGEN_SRC/src/ATOMGENGUI/ATOMGENGUI.py which is within SALOME sources.