Gui for node generation in Hypermesh
- Admin
- Nov 25
- 2 min read
Creating nodes in FEA doesn’t have to be complicated. A simple script can generate nodes with IDs and X, Y, Z coordinates automatically. You can even renumber them to keep the model organized.
Using commands like createnode and renumbersolverid, engineers can quickly set up nodes for any structure without manual entry. This saves time and avoids mistakes.
Even a short, clean script makes preparing a model much easier and faster.
Here is an clean example for Hypermesh.

proc CreateColumns {tree1} {
$tree1 columncreate col1 -text "Node ID"
$tree1 columncreate col2 -text "Position X"
$tree1 columncreate col3 -text "Position Y"
$tree1 columncreate col4 -text "Position Z"
}
proc Populate {tree1 num} {
if {![string is integer -strict $num]} {
tk_messageBox -type ok -icon error -title "Error" \
-message "Node number must be an integer"
return
}
foreach r [$tree1 rowlist] {
$tree1 rowdelete $r
}
array unset ::Var1
array set ::Var1 {}
for {set i 0} {$i < $num} {incr i} {
set rowid [$tree1 rowinsert end rownew]
set ::Var1($rowid,col1) ""
set ::Var1($rowid,col2) ""
set ::Var1($rowid,col3) ""
set ::Var1($rowid,col4) ""
$tree1 cellset $rowid col1 ""
$tree1 cellset $rowid col2 ""
$tree1 cellset $rowid col3 ""
$tree1 cellset $rowid col4 ""
}
$tree1 liveupdate 1
}
# ==========================================================
# Main GUI
# ==========================================================
proc nodeGenerator {} {
if {[winfo exists .window]} { destroy .window }
set win .window
toplevel $win -class TopClass -width 800 -height 1200 -padx 10 -pady 10
wm title $win "Node Generator Tool"
wm resizable $win 1 1
wm deiconify $win
pack [hwtk::notebook $win.nb] -fill both -expand 1
$win.nb add [frame $win.nb.f10] -text "Node Generator"
label $win.nb.f10.l1 -text "Enter number of nodes"
place $win.nb.f10.l1 -x 10 -y 10 -width 250 -height 30
hwtk::entry $win.nb.f10.e1 -textvariable ::nodeNumber
place $win.nb.f10.e1 -x 300 -y 10 -width 250 -height 30
button $win.nb.f10.b1 -text "Generate Table" \
-font {times 10 bold} -command {
if {![info exists ::nodeNumber] || $::nodeNumber eq ""} {
tk_messageBox -type ok -icon warning -title "Warning" \
-message "Please enter number of nodes"
return
}
if {[winfo exists $::win.nb.f10.tree1]} {
destroy $::win.nb.f10.tree1
}
set t [hwtk::datatable $::win.nb.f10.tree1 -variable ::Var1]
place $::win.nb.f10.tree1 -x 10 -y 250 -width 550 -height 600
CreateColumns $t
Populate $t $::nodeNumber
}
place $win.nb.f10.b1 -x 10 -y 150 -width 250 -height 30
button $win.nb.f10.b2 -text "Generate Nodes" \
-font {times 10 bold} -command { gennodes }
place $win.nb.f10.b2 -x 300 -y 150 -width 250 -height 30
}
proc gennodes {} {
if {![info exists ::nodeNumber] || ![string is integer -strict $::nodeNumber]} {
tk_messageBox -type ok -icon error -title "Error" -message "Invalid node number"
return
}
set total $::nodeNumber
puts "----- NODE GENERATION START -----"
foreach rowid [$::win.nb.f10.tree1 rowlist] {
set nodeID [.window.nb.f10.tree1 cellget $rowid col1]
set x [.window.nb.f10.tree1 cellget $rowid col2]
set y [.window.nb.f10.tree1 cellget $rowid col3]
set z [.window.nb.f10.tree1 cellget $rowid col4]
if {$x eq "" || $y eq "" || $z eq ""} {
puts "Skipping empty row $rowid"
continue
}
puts "Create Node: ID=$nodeID X=$x Y=$y Z=$z"
*createnode $x $y $z 0 0 0
*createmarklast nodes 1
*renumbersolverid nodes 1 $nodeID 1 0 0 0 0 0
*clearmark nodes 1
}
puts "----- NODE GENERATION COMPLETE -----"
}
# ==========================================================
# START
# ==========================================================
nodeGenerator


Excellent example for creating gui👍