to call a *.tcl file from within a *.cmf file

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

Hi,

I am a new user of tcl/tk and using it for the first time to do some pre-processing in the batch mode. I have currently created a *.cmf file which does all the preprocessing on an optimisation model. While preprocessing, the loads, BC's are all applied in HM (batch mode). The 'Force Load' is applied on a set of nodes stored as 'ndload' in HM and is 5000N. So the nett force on each node will be 5000/number of nodes in 'ndload' set.

I need to extract the number of nodes in this set (coz the number of nodes change as the geometry changes), then do the math (5000/no. of nodes) and finally apply this new force load on the nodes in “ndload” set.

I have put together a few tcl commands as shown below that would probably do this job. But how can I get this tcl file to work when I run my cmf file in the batch mode (these tcl commands would have to be called while running the cmf file).

###############

set num_nodes [llength [hm_getentityarray sets ndload nodes -byname]]

set force [expr [5000 / $num_nodes]]

*createmark nodes 1 'by sets' ndload

eval *loadcreateonentity_curve nodes 1 1 1 0 $force 0 0 0 1 0 0 0 0 0

*createmark loads 1 'by loadcols' force

*attributeupdateentitymark loads 1 45 9 1 0 curves 1

*createmark loads 1 'by loadcols' force

*attributeupdateintmark loads 1 4172 9 2 0 0

###################

I would be grateful if someone could tell me how I can use these tcl commands to work as part of my *.cmf file.

Thanks in advance,

Felix

Tagged:

Answers

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

    there is a command that start with *eval , just look into the help system. I do not recall the exact command name. just use the help system and you will answer your question.

    or, in hypermesh, in the display tab, turn off the connectors. then, take a look into the command.cmf file and the last command is the one to run a tcl from a cmf file.

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

    Dear Cesar,

    The command to invoke a tcl scipt from within a cmf file is *evaltclstring('source filepath/name.tcl',0)

    However, in this case, there is no need to include the begin macro and end macro coomands in the tcl script.

    Thank a lot for the tip.

    Felix

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.