Jump to content
Sign in to follow this  
Guest

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

Recommended Posts

Guest

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

Share this post


Link to post
Share on other sites
Guest

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

Share this post


Link to post
Share on other sites
Guest

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!

Share this post


Link to post
Share on other sites
Guest

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

Share this post


Link to post
Share on other sites
Guest

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

Share this post


Link to post
Share on other sites
Guest

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

Share this post


Link to post
Share on other sites
Guest

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

Share this post


Link to post
Share on other sites
Guest

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

Share this post


Link to post
Share on other sites
Guest

*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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...