Tcl or tool command language is a tool language that can be use to make several hypermesh process automated, I am assuming you understand basic coding and hypermesh. lets see some scripts given below and try to figure out the use of different syntex
When we start hyperworks and start doing several operations a file command.tcl is automatically created having all the codes written for all operations we are doing.
#command.tcl after creating a simple sphere
*drawlistresetstyle
*createnode 0 0 0 0 0 0
*surfacemode 4
*surfacespherefull 520 10
puts “hello_World”
*createmark comp 1 all
set compIds [hm_getmark comp 1]
foreach compId $compIds {
set compname [hm_getvalue comp id =$compId dataname=name]
puts $compname
}
*createmark comp 1 all
set compIds [hm_getmark comp 1]
foreach compId $compIds {
set compname [hm_getvalue comp id =$compId dataname=name]
*createmark elem 1 $compId
set noofelem [hm_marklength elem 1]
puts $compname\t$noofelem
}
For loop application with expression
A for loop is a repetition control structure that allows you to efficiently write a code that needs to be executed for a specific number of times.
for {initialization} {condition} {increment} {
statement(s);
}
# Command for adding two number
expr {1+2}
#command for printing numbers 11 to 20
for { set a 10} {$a < 20} {incr a} {
puts "value of a: $a"
}
for {set x 0} {$x < 10} {incr x} {*createnode $x 0 0 0 0 0}