Select nodes/Elements by location using a script?
Up to Use
Select nodes/Elements by location using a script?
Is it possible to select nodes/elements by location using a script? for example let's say there is a node at (100,0,0). Or an element that contains nodes 1,2,3 at locations (100,0,0) (100,1,0) (101,1,0). I've been looking through the documentation off and on for the last couple of weeks but can't seem to sort out the TUI stuff.
Thanks,
Peter
Re: Select nodes/Elements by location using a script?
To select a node you can use:
id_node = Mesh.FindNodeClosestTo(x, y, z)
To select elements by a point coordinates:
l_id_elements = Mesh.FindElementsByPoint(x, y, z)
You can open the file SMESH/bin/salome/smeshDC.py to browse all the smesh methods. In my opinion, it's much more convenient than browsing the online help 
Christophe
Re: Select nodes/Elements by location using a script?
Previously Christophe Bourcier wrote:
You can open the file SMESH/bin/salome/smeshDC.py to browse all the smesh methods. In my opinion, it's much more convenient than browsing the online help
Brilliant! Absolutely brilliant!
Previously Christophe Bourcier wrote:
To select a node you can use:
id_node = Mesh.FindNodeClosestTo(x, y, z)
To select elements by a point coordinates:
l_id_elements = Mesh.FindElementsByPoint(x, y, z)
You can open the file SMESH/bin/salome/smeshDC.py to browse all the smesh methods. In my opinion, it's much more convenient than browsing the online help
Christophe
Hello,
I am new to programming in Python and in Salome TUI, so I need some low level help! I am trying what you suggested above but have not succeeded so far. I have tried:
import MESH
ImportError: No module named MESH
dir(MESH) : .... long list ... but no FindElementsByPoint
import Mesh:
ImportError: No module named Mesh
import(smesh)
dir(smesh) : .... long list ... but no FindElementsByPoint
import SMESH
dir(SMESH) : .... long list ... but no FindElementsByPoint
import smeshDC
elem = smeshDC.FindElementsByPoint(x,y,z, SMESH.ALL)
AttributeError: 'module' object has no attribute 'FindElementsByPoint'
dir(smeshDC) : .... long list ... but no FindElementsByPoint
I see a 'def FindElementByPoint()' in .../bin/salome/smeshDC.py so why doesn't it work?! How should even begin...? Thanks for any help.
Regards,
JMB
Re: Select nodes/Elements by location using a script?
Are you trying it in the python code window inside Salome or are you opening python. You need to source the environment to be able to use python. When I get time I'll upload an example here.
Previously pete Halverson wrote:
Are you trying it in the python code window inside Salome or are you opening python. You need to source the environment to be able to use python. When I get time I'll upload an example here.
Hello Pete,
I am trying it inside Salome (in its command window), which is why I am puzzled. Do I specifically need to be viewing a VTK window, because that is one thing I did not try. Meshing TUIs I have written work quite well regardless of which viewer is open (OCC / VTK). Yes an example would be very useful, thank you!
Regards,
JMB

