Run a Script from the TCL window in hypermesh
Best Answer
-
María Plata said:
Thank you for replying!!
I want to create a database of pictures to train afterwards a neural network. In order to do that, I want to automate the process by using a tcl script that has this main three functions:
1- Prepare the Hypermesh model with the necessary boundary conditions to be compiled. ✅
2- Export the .fem model, and run the solver to obtain the results. ❌
3- Evaluate the results and take a screencapture. ✅
So far, I have being trying different codes but I cannot find a complete file that works none of them runs the simulation.
When I manually run the simulation, I cannot obtain, in the file 'comand.txt' ,the necessary code to compile the file. The only part saved in this txt file is the the one related with part 1 and 3.
*createstringarray 5 "HM_NODEELEMS_SET_COMPRESS_SKIP " "EXPORT_DMIG_LONGFORMAT " \
"HMMATCOMMENTS_XML" "HMBOMCOMMENTS_XML" "INCLUDE_RELATIVE_PATH "
*feoutputwithdata "C:/Program Files/Altair/2022.2/hwdesktop/templates/feoutput/optistruct/optistruct" "D:/ADRIANO/export.fem" 0 0 2 1 5This is the basic command.
To get this, I've launched my model manually in HyperWorks, and exported the file as a .fem model for OptiStruct.
Once I did that, I went to the command.tcl file and this was automatically written there.
Nor to run your model, you need to call:
exec {install_folder/.....optistruct.bat} "model_folder/export.fem"
1
Answers
-
by compile, you mean export your .fem model, and run the solver?
could you elaborate better what are you trying to do?
In general, what I do for creating a script is to manually perform the operations in HM, and after doing that, open the command.tcl files (usually Documents folder), and extract from there the main commands to build my customizaed script.
Once I do that, I adjust the commands with more generic options, by enriching the script with a couple TCL programming commands, and variables.
1 -
Thank you for replying!!
I want to create a database of pictures to train afterwards a neural network. In order to do that, I want to automate the process by using a tcl script that has this main three functions:
1- Prepare the Hypermesh model with the necessary boundary conditions to be compiled. ✅
2- Export the .fem model, and run the solver to obtain the results. ❌
3- Evaluate the results and take a screencapture. ✅
So far, I have being trying different codes but I cannot find a complete file that works none of them runs the simulation.
When I manually run the simulation, I cannot obtain, in the file 'comand.txt' ,the necessary code to compile the file. The only part saved in this txt file is the the one related with part 1 and 3.
0 -
María Plata said:
Thank you for replying!!
I want to create a database of pictures to train afterwards a neural network. In order to do that, I want to automate the process by using a tcl script that has this main three functions:
1- Prepare the Hypermesh model with the necessary boundary conditions to be compiled. ✅
2- Export the .fem model, and run the solver to obtain the results. ❌
3- Evaluate the results and take a screencapture. ✅
So far, I have being trying different codes but I cannot find a complete file that works none of them runs the simulation.
When I manually run the simulation, I cannot obtain, in the file 'comand.txt' ,the necessary code to compile the file. The only part saved in this txt file is the the one related with part 1 and 3.
*createstringarray 5 "HM_NODEELEMS_SET_COMPRESS_SKIP " "EXPORT_DMIG_LONGFORMAT " \
"HMMATCOMMENTS_XML" "HMBOMCOMMENTS_XML" "INCLUDE_RELATIVE_PATH "
*feoutputwithdata "C:/Program Files/Altair/2022.2/hwdesktop/templates/feoutput/optistruct/optistruct" "D:/ADRIANO/export.fem" 0 0 2 1 5This is the basic command.
To get this, I've launched my model manually in HyperWorks, and exported the file as a .fem model for OptiStruct.
Once I did that, I went to the command.tcl file and this was automatically written there.
Nor to run your model, you need to call:
exec {install_folder/.....optistruct.bat} "model_folder/export.fem"
1 -
Adriano A. Koga_21884 said:
*createstringarray 5 "HM_NODEELEMS_SET_COMPRESS_SKIP " "EXPORT_DMIG_LONGFORMAT " \
"HMMATCOMMENTS_XML" "HMBOMCOMMENTS_XML" "INCLUDE_RELATIVE_PATH "
*feoutputwithdata "C:/Program Files/Altair/2022.2/hwdesktop/templates/feoutput/optistruct/optistruct" "D:/ADRIANO/export.fem" 0 0 2 1 5This is the basic command.
To get this, I've launched my model manually in HyperWorks, and exported the file as a .fem model for OptiStruct.
Once I did that, I went to the command.tcl file and this was automatically written there.
Nor to run your model, you need to call:
exec {install_folder/.....optistruct.bat} "model_folder/export.fem"
Thank you very much!!
The simulation seems to run but stops with the following error:
Unknown analysisparameter data type "real_eigen_type" found in file.
This error doesn't appear when I run it manually. Do you know what could be the problem?
0 -
María Plata said:
Thank you very much!!
The simulation seems to run but stops with the following error:
Unknown analysisparameter data type "real_eigen_type" found in file.
This error doesn't appear when I run it manually. Do you know what could be the problem?
are you sure the file is getting created and exported in the OptiStruct user profile?
If you're running HyperWorks in batch mode, you will need to set the user profile to the correct solver (i.e OptiStruct) before even exporting the model, otherwise your solvers cards might be incorrect.
When you do that manually, you're probably already at the correct solver interface/user profile.
Could you share what are the commands that you're using to call HW in batch?
1 -
Adriano A. Koga_21884 said:
are you sure the file is getting created and exported in the OptiStruct user profile?
If you're running HyperWorks in batch mode, you will need to set the user profile to the correct solver (i.e OptiStruct) before even exporting the model, otherwise your solvers cards might be incorrect.
When you do that manually, you're probably already at the correct solver interface/user profile.
Could you share what are the commands that you're using to call HW in batch?
Oh I didn't call the solver OptiStruct in HW. I thought that running it from the TCL console in Hyperworks would be enough. How should I do it?
So far my code is as follows:
*createstringarray 5 "HM_NODEELEMS_SET_COMPRESS_SKIP " "EXPORT_DMIG_LONGFORMAT " \ "HMMATCOMMENTS_XML" "HMBOMCOMMENTS_XML" "INCLUDE_RELATIVE_PATH "
*feoutputwithdata "C:/Programme/altair/2021.1/hwdesktop/templates/feoutput/optistruct/optistruct" "H:/hyperworks2.0/resultswithTCL/iterar/Results01TCL.fem" 0 0 2 1 5
0 -
María Plata said:
Oh I didn't call the solver OptiStruct in HW. I thought that running it from the TCL console in Hyperworks would be enough. How should I do it?
So far my code is as follows:
*createstringarray 5 "HM_NODEELEMS_SET_COMPRESS_SKIP " "EXPORT_DMIG_LONGFORMAT " \ "HMMATCOMMENTS_XML" "HMBOMCOMMENTS_XML" "INCLUDE_RELATIVE_PATH "
*feoutputwithdata "C:/Programme/altair/2021.1/hwdesktop/templates/feoutput/optistruct/optistruct" "H:/hyperworks2.0/resultswithTCL/iterar/Results01TCL.fem" 0 0 2 1 5
Hi,
What I meant was before that, actually.
1) before exporting the model, you need to be sure that both the feoutput template is correct (which apparently it is), AND when you call HyperWorks, it is launch in the OptiStruct user profile, so that your script for building the model is correctly creating the correct cards.
2) assuming that the model was exported correctly to some solver, then you can embed this call in your TCL script to call the OptiStruct solver:
exec {install_folder/.....optistruct.bat} "model_folder/export.fem"
1 -
Adriano A. Koga_21884 said:
Hi,
What I meant was before that, actually.
1) before exporting the model, you need to be sure that both the feoutput template is correct (which apparently it is), AND when you call HyperWorks, it is launch in the OptiStruct user profile, so that your script for building the model is correctly creating the correct cards.
2) assuming that the model was exported correctly to some solver, then you can embed this call in your TCL script to call the OptiStruct solver:
exec {install_folder/.....optistruct.bat} "model_folder/export.fem"
This is the code I get when I export it in the TCL console from Hyperworks,
is command good written?
The batch command was found in the following folder.
0 -
María Plata said:
This is the code I get when I export it in the TCL console from Hyperworks,
is command good written?
The batch command was found in the following folder.
can you do some testing?
If you open Windows command (CMD), and try to run a similar command, does it work?
1 -
Adriano A. Koga_21884 said:
can you do some testing?
If you open Windows command (CMD), and try to run a similar command, does it work?
I get the same message
0 -
María Plata said:
I get the same message
time to re-check your HyperWorks Solvers intallation.
1 -
Adriano A. Koga_21884 said:
time to re-check your HyperWorks Solvers intallation.
All right!! I will try to re-download it. Thank you for your support!!
0 -
Adriano A. Koga_21884 said:
time to re-check your HyperWorks Solvers intallation.
Hi Adriano, it's Maria again!
I had re-installed all Hyperworks with tcl commands again, but it still doesn't work! I would like to ask you how do you get your in your "command tcl file" the commands to run the file.
In other words, my tcl file writes automatically every change until I run the simulation. Once I run the simulation, I don't get the commands for running the simulation written done in the file or the following commands to plot the result.
How can I modify my tcl file to obtain every command?
0 -
María Plata said:
Hi Adriano, it's Maria again!
I had re-installed all Hyperworks with tcl commands again, but it still doesn't work! I would like to ask you how do you get your in your "command tcl file" the commands to run the file.
In other words, my tcl file writes automatically every change until I run the simulation. Once I run the simulation, I don't get the commands for running the simulation written done in the file or the following commands to plot the result.
How can I modify my tcl file to obtain every command?
are you able to run the model directly from the GUI?
Additionally, what is you license? Is it a student version? If this is student, I think it doesn't allow to run from the command line.
0 -
Adriano A. Koga_21884 said:
are you able to run the model directly from the GUI?
Additionally, what is you license? Is it a student version? If this is student, I think it doesn't allow to run from the command line.
Hi Adriano,
Thank you so much for your help!! Apparently I needed all the commands to make it work. In case someone needs it:
*createstringarray 1 "CONNECTORS_SKIP "
*feoutputwithdata "C:/Program Files/Altair/2021.2/hwdesktop/templates/feoutput/optistruct/optistruct" "E:/MA_Plata/primerasimu/intento/Simulation0.fem" 1 0 2 1 1
exec "C:/Program Files/Altair/2021.2/hwsolvers/scripts/optistruct" "E:/MA_Plata/primerasimu/intento/Simulation0.fem" -len 16000 -nt 12I would like to ask you something more. If I want to run automatically simulations in line, i.e queuing the simulations. Is there any command that can help me wait for the simulation to be completed to run the following one?
Thank you so much again
0 -
María Plata said:
Hi Adriano,
Thank you so much for your help!! Apparently I needed all the commands to make it work. In case someone needs it:
*createstringarray 1 "CONNECTORS_SKIP "
*feoutputwithdata "C:/Program Files/Altair/2021.2/hwdesktop/templates/feoutput/optistruct/optistruct" "E:/MA_Plata/primerasimu/intento/Simulation0.fem" 1 0 2 1 1
exec "C:/Program Files/Altair/2021.2/hwsolvers/scripts/optistruct" "E:/MA_Plata/primerasimu/intento/Simulation0.fem" -len 16000 -nt 12I would like to ask you something more. If I want to run automatically simulations in line, i.e queuing the simulations. Is there any command that can help me wait for the simulation to be completed to run the following one?
Thank you so much again
honestly i don't have the exact answer, but I believe if you write some commands inside your batch, to keep checking if there's a particular file in your folder, such as the .h3d file in the end, it might help you.
i.e: check the existence of the .h3d file after 30seconds, then if it is there, go ahead, otherwise, wait for 30s more.
There might be some other better option.
According to ChatGPT
For example, if you have three batch files named "first.bat", "second.bat", and "third.bat" in the same directory as your script, you can modify the script like this:
bashCopy code@<span class="hljs-built_in" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #e9950c;">echo</span> off start /wait <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">"First Batch File"</span> <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">"first.bat"</span> start /wait <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">"Second Batch File"</span> <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">"second.bat"</span> start /wait <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">"Third Batch File"</span> <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">"third.bat"</span>
The "/wait" option will still wait for each batch file to finish before proceeding to the next line of the script. Note that the file paths are relative to the current working directory of the script, so make sure your batch files are in the same directory as the script or specify the full path to them.
0