distance between two nodes
-
-
I realize that is not possible to get the distance between two nodes. So I am using a awk script to calculate that distance. But still is not a elegant solution. I want to calculate inside salome. But I am new in python. I am trying to access the node coordinates following the weida's script but in the python console when I write something like this import smesh pequeno=small.GetMesh() I got the following error Traceback (most recent call last): File "<input/>", line 1, in ? NameError: name 'small' is not defined. My mesh in the left window has the name small. So what is the problem? Thank you in advance.
-
Hi, Paco.
You can write in the python console the following commands
import math
study = salome.myStudyManager.GetStudyByName("Study1"
theSObj = study.FindObject("small"
MObject = theSObj.GetObject()
node1=1
node2=48
coord1=MObject.GetNodeXYZ(node1)
coord2=MObject.GetNodeXYZ(node2)
distance=math.sqrt((coord1[0]-coord2[0])*(coord1[0]-coord2[0])+(coord1[1]-coord2[1])*(coord1[1]-coord2[1])+(coord1[2]-coord2[2])*(coord1[2]-coord2[2]))
print distanceSure "Study1", "small", 1, 48 can be replaced by any relevant values. Or write function to use these values as arguments if you plan to use it often.
Regards,
Grigory
-
-
