How to get nearest node of other component with the help of temp node from component 1?

Bhavik Sheth_21143
Bhavik Sheth_21143 Altair Community Member
edited August 2023 in Community Q&A

Hello Team,

I am new into customization of Hypermesh.

I have one question which I tried to explain in attached image.

Question: I have a list of nodes with ids and co-ordinates from Component 1 and I want to find the nearest node from Component 2 to that respective node from Comp 1. How to do achieve that?

 

Any help will be great.

Thank you in advance.

HM.PNG 242.4K

Welcome!

It looks like you're new here. Sign in or register to get started.

Best Answer

  • Ben Buchanan
    Ben Buchanan
    Altair Employee
    edited August 2023 Answer ✓

    Hi Ben,

    Thanks for the suggestion.

    I have used below method. Is that ok?

    set refNodeCoord [hm_getvalue nodes id=[lindex $TempNodesList_1 0] dataname=coordinates]
            puts $refNodeCoord
            
            hm_markclear comps 2
            hm_markclear elems 2
             
            hm_createmark comps 2 $Comp2_Name
            hm_createmark elems 2 "by comps on mark" 2
            
            set refCloseNode [hm_getclosestnode [lindex $refNodeCoord 0] [lindex $refNodeCoord 1] [lindex $refNodeCoord 2] 2]
            #Get ID of Last created Node
            set pnt [TheLast node]
             
             set ref2Pnt [hm_getvalue nodes id=$pnt dataname=coordinates]
             puts $ref2Pnt
            
             hm_markclear comps 2
             hm_markclear elems 2

    I would make the following changes:

       set refNodeCoord [hm_getvalue nodes id=[lindex $TempNodesList_1 0] dataname=coordinates]
            puts $refNodeCoord
            
            *clearmarkall 2
             
            hm_createmark comps 2 $Comp2_Name
            hm_createmark elems 2 "by comps on mark" 2
            
            set refCloseNode [hm_getclosestnode {*}$refNodeCoord 2]
             
             set ref2Pnt [hm_getvalue nodes id=$refCloseNode dataname=coordinates]
             puts $ref2Pnt
            
             *clearmarkall 2

Answers

  • Ben Buchanan
    Ben Buchanan
    Altair Employee
    edited August 2023

    The hm_getclosestnode should get you what you want if you pick elements by component.
    https://help.altair.com/hwdesktop/hwd/topics/reference/hm/hm_getclosestnode.htm

  • Bhavik Sheth_21143
    Bhavik Sheth_21143 Altair Community Member
    edited August 2023

    Hi Ben,

    Thanks for the suggestion.

    I have used below method. Is that ok?

    set refNodeCoord [hm_getvalue nodes id=[lindex $TempNodesList_1 0] dataname=coordinates]
            puts $refNodeCoord
            
            hm_markclear comps 2
            hm_markclear elems 2
             
            hm_createmark comps 2 $Comp2_Name
            hm_createmark elems 2 "by comps on mark" 2
            
            set refCloseNode [hm_getclosestnode [lindex $refNodeCoord 0] [lindex $refNodeCoord 1] [lindex $refNodeCoord 2] 2]
            #Get ID of Last created Node
            set pnt [TheLast node]
             
             set ref2Pnt [hm_getvalue nodes id=$pnt dataname=coordinates]
             puts $ref2Pnt
            
             hm_markclear comps 2
             hm_markclear elems 2

  • Ben Buchanan
    Ben Buchanan
    Altair Employee
    edited August 2023 Answer ✓

    Hi Ben,

    Thanks for the suggestion.

    I have used below method. Is that ok?

    set refNodeCoord [hm_getvalue nodes id=[lindex $TempNodesList_1 0] dataname=coordinates]
            puts $refNodeCoord
            
            hm_markclear comps 2
            hm_markclear elems 2
             
            hm_createmark comps 2 $Comp2_Name
            hm_createmark elems 2 "by comps on mark" 2
            
            set refCloseNode [hm_getclosestnode [lindex $refNodeCoord 0] [lindex $refNodeCoord 1] [lindex $refNodeCoord 2] 2]
            #Get ID of Last created Node
            set pnt [TheLast node]
             
             set ref2Pnt [hm_getvalue nodes id=$pnt dataname=coordinates]
             puts $ref2Pnt
            
             hm_markclear comps 2
             hm_markclear elems 2

    I would make the following changes:

       set refNodeCoord [hm_getvalue nodes id=[lindex $TempNodesList_1 0] dataname=coordinates]
            puts $refNodeCoord
            
            *clearmarkall 2
             
            hm_createmark comps 2 $Comp2_Name
            hm_createmark elems 2 "by comps on mark" 2
            
            set refCloseNode [hm_getclosestnode {*}$refNodeCoord 2]
             
             set ref2Pnt [hm_getvalue nodes id=$refCloseNode dataname=coordinates]
             puts $ref2Pnt
            
             *clearmarkall 2

  • Bhavik Sheth_21143
    Bhavik Sheth_21143 Altair Community Member
    edited August 2023

    Thank you so much for the guidance.

    It works as required.

     

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.