How to get node id from coordinates?

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Hi All,

 

I have x, y ,z coordinates  and I have  system ID also.

Eg: {0 0 25} and system ID :658001

Suppose, a node is present in the model at the above location, How to get the node ID using HM APIs?

Note :hm_closest node is not working for me.

 

Regards

Gopal

Answers

  • tinh
    tinh Altair Community Member
    edited March 2018

    Hi

    sure, hm_getclosestnode is not working with local coordinate, you have to provide global coordinate

    maybe, there is some commands to calculate global coordinate, please search them

    below I will create a node at that position, and retrieve its global coordinate to provide to hm_getclosestnode

    *createnode 0 0 25 658001 ; #create a node at the coordinate

    set NodeId [hm_latestentityid nodes]

    set gx [hm_getentityvalue nodes $NodeId globalx 0]

    set gy [hm_getentityvalue nodes $NodeId globaly 0]

    set gz [hm_getentityvalue nodes $NodeId globalz 0]

    *createmark nodes 1 -1

    *nodemarkcleartempmark

    puts [hm_getclosestnode $gx $gy $gz]

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2018

    Hi tinh,

     

    Thanks for your suggestion.

     

    Regards

    Gopal