TCL hypermesh for begineers

#TCL for hypermesh #TCL hypermesh #Automation

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

  1. Comment- #text
  2. print text - put "text"
  3. set - set [entities]

Now we will discuss about some scripting examples we used some syntax given below

Syntex name Syntex Example Use
Comment#Text#commentTo write comments in program
PrintPut "text"Put "hello World"Printing text
Setset [entities]set [1 2 3 4]Creating set of anything
foreachforeach name set {
#user commands
}
shown belowillustrated below

Writing a script

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

Mobirise

Explanation

1

Creating a set of component ids

*createmark comp 1 all
set compIds [hm_getmark comp 1] 

2

Creating a set of component name using hm_getvalue & foreach

foreach compId $compIds {
set compname [hm_getvalue comp id =$compId dataname=name] 

3

Creating set of no. of element and pring all sets

*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"

}

Write a script for making 10 nodes equidistant 1 units in x directions

use "*createnode X Y X 0 0 0" for creating node

for {set x 0} {$x < 10} {incr x} {*createnode $x 0 0 0 0 0}

Mobirise
Mobirise

#if statement in for
 for { set a 10} {$a < 20} {incr a} {

if {$a > 13 && $a <17 } {
puts $a
puts “_is_between_13-17”
continue
}

puts $a

E-mail

beginfea@gmail.com

Phone

+91 9599 755915

Whatsapp

+91 9599 755915

Built with Mobirise html website template