Personal tools
You are here: Home Forum Use distance between two nodes

distance between two nodes

Up to Use
  • distance between two nodes

    Posted by paco_espinola at April 23. 2007

    How can I get the distance between two nodes?

    I am using salome 3.2.1

    • Re: distance between two nodes

      Posted by paco_espinola at April 25. 2007
      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/>&quot;, 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.
      • Re: distance between two nodes

        Posted by Grigory Zhivotovsky at April 25. 2007

        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 distance

        Sure "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

Powered by Ploneboard
Document Actions