check node coordinates(x,y,z), NodeID and its mother element, ElementID and its nodes

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

Hi Group,

would anyone give some hints to make it using macro or TCL/TK?

in addtion, I would like to search/find the closest elementID.

Thank in advance for any advices!

Sternchen

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2008

    Sternchen

    There are a number of existing TCL macro scripts in the install directory of HyperMesh ...\hm\scripts organized for each solver. These are the same ones that are activated by the 'Utility' menu in HyperMesh that change for each User Profile that you select. They range from relatively straightforward ones (i.e. dynakey\findfreerigids.tcl) to more complex ones that create their own GUI panels (nastran\tablecomps.tcl).

    There are also some examples from users if you go the 'macro exchange' area on the www.altairhyperworks.com website.

    You may want to start creating a macro by reviewing a series of commands that you perform in HyperMesh that get recorded in your command.cmf file. You can basically use any 'macro' command in TCL, plus all the TCL commands for loops, logic, file management, etc. The main difference is for TCL, you have to remove all the parentheses and commas between data fields. To create a node in TCL, you would enter

    *createnode 1 1 1 0 0 0
    Have a look in the online help for HyperMesh - Reference Guide, Utility Menu and Tcl/Tk, Programming HyperMesh with Tcl/Tk for more info.

    Cheers,

    Eric

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2008

    Eric,

    Thanks for your advices regarding the general guideline for using TCL/TK, HM Macro.

    But maybe you have missed the thread title.

    I want to find a *hm_??? command to find a certain node's coordinates(x,y,z) and its belonging element IDs, and so far also the neighbor element IDs...

    The most related command I could find now is:

    hm_getcoordinates

    But it only support points not node.

    I really do not want to dig into the hmlibs & C++ etc... :-)

    Regards!

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2008

    To get the coordinates of a node, you can use

    set  CoordX [hm_getentityvalue NODE $n1 'x' 0]set  CoordY [hm_getentityvalue NODE $n1 'y' 0]set  CoordZ [hm_getentityvalue NODE $n1 'z' 0]
    Search for 'Data names' in the online help - the same command can be used to get the node id values for an element in your model.

    To find which elements are attached to a node (there can be many more than 1), use the find command:

    *clearmark nodes 1*clearmark elems 2eval *createmark nodes 1 $n1*findmark nodes 1 1 1 elems 0 2set list_of_elems [hm_getmark elems 2]
    Hope this helps

    Eric

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2008

    Eric, you are great! That was exactly I want.

    You just opened the door to me.

    Thanks!

    To get the coordinates of a node, you can use

    set  CoordX [hm_getentityvalue NODE $n1 'x' 0]set  CoordY [hm_getentityvalue NODE $n1 'y' 0]set  CoordZ [hm_getentityvalue NODE $n1 'z' 0]
    Search for 'Data names' in the online help - the same command can be used to get the node id values for an element in your model.

    To find which elements are attached to a node (there can be many more than 1), use the find command:

    *clearmark nodes 1*clearmark elems 2eval *createmark nodes 1 $n1*findmark nodes 1 1 1 elems 0 2set list_of_elems [hm_getmark elems 2]
    Hope this helps

    Eric

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited April 2008

    Another version could be:

    foreach {CoordX CoordY CoordZ} [join [hm_nodevalue $n1]] {}

    Important is, that hm_nodevalue returns a tcl-list of all 3 coordinates.

    Greetings

    Thomas

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited September 2008

    Hi:

    I want to get the nodal positions of the displayed nodes and compare their 'X' positions and get the max and min of those.

    I am a newbie and I am stuck here:

    *createmark nodes 1 'displayed'

    set nodelist [ hm_getmark nodes 1];

    set length [llength nodelist]

    tk_messageBox -message '$length !'

    when I print the $length variable, I expect it to print the # of displayed nodes and it just prints '1'. Can anyone please help me how do I proceed from here

    Thanks much in advance

    Dinesh.M

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited September 2008

    Hey Dinesh

    There's a simple solution to your problem. The command llength is expecting to see a list of entries, so it is counting 'nodelist' as 1 item. For it to count the contents of your variable, you need to put a $ in front

    *createmark nodes 1 'displayed'set nodelist [hm_getmark nodes 1]set length [llength $nodelist]puts ' list is $length nodes'

    Good luck,

    Eric

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited October 2008

    *createmark nodes 1 'displayed'

    set nodelist [hm_getmark nodes 1];

    I would continue like this:

    foreach {CoordX CoordY CoordZ} [join [hm_nodevalue [lindex $nodelist 0]]] {}set minX $CoordX; set maxX $CoordX ;# initializationforeach nID $nodelist {    foreach {CoordX CoordY CoordZ} [join [hm_nodevalue $nID]] {}    if {$CoordX < $minX} {set minX $CoordX}    if {$CoordX > $maxX} {set maxX $CoordX}    # do the same for Y and Z if you need it ...}
    puts 'minX = $minX\nmaxX = $maxX'

    If you do not like the more complex 'foreach and hm_nodevalue construct' you can use 'hm_getentityvalue' as shown above.

    Good luck

    thomas

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited September 2020

    Is there an alternative to 

     

     set nodelist [hm_getmark nodes 1]

     

    to get a list of all the node ids in the model that will run quickly for large meshes?

  • Q.Nguyen-Dai
    Q.Nguyen-Dai Altair Community Member
    edited September 2020

    What's your goal? Output node-ID & coordinates?

  • tinh
    tinh Altair Community Member
    edited September 2020

    Is there an alternative to 

     

      set nodelist [hm_getmark nodes 1]

     

    to get a list of all the node ids in the model that will run quickly for large meshes?

     

    Use 

    set nodelist [hm_entitylist node]

    It runs faster than *createmark and hm_getmark

     

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited September 2020

    Thanks tinh!

     

    I had to change it to

     

     set nodelist [hm_entitylist nodes id]

     

    but it worked out