How is the thickness of PSHELL in properties changed from .bat and .tcl files?
Hi, there,
I use HyperMesh 2019 in Windows 10. I want to change the thickness T of PSHELL in Properties with .bat and .tcl files automatically. I used the bat and tcl files below.
- changethickness.bat
cd /d %~dp0
"C:\Program Files\Altair\2019\hm\bin\win64\hmbatch.exe" -tcl change.tcl
- change.tcl
set tps 10
*readfile changethicknesstest.hm
*setvalue props name="PSHELL BATCHTEST" STATUS=1 95=$tps
*writefile changethicknesstest.hm 1
However, when changethickness.bat is executed from command prompt, the error is shown below.
Altair HyperMesh v2019.0.0.70
Copyright (C)1990-2019 - Altair Engineering, Inc. All Rights Reserved.
Contains trade secrets of Altair Engineering, Inc. Copyright notice does not
imply publication. Decompilation or disassembly of this software is strictly
prohibited.
Error: Data-name or numeric code is not valid
0
while executing
"*setvalue props name="PSHELL BATCHTEST" STATUS=1 95=$tps"
(file "change.tcl" line 3)
invoked from within
"source change.tcl"
End of command file - terminating.
HM exiting with code 1
Although I try to run the same tcl file from GUI (File > Run > Tcl/Tk Script), it works normaly. When the line 3 is deleted from the tcl file, the bat file is executed also. Therefore, *setvalue does not work only when it is executed by bat file.
How do I change the thickness with bat and tcl files?
Best Answer
-
Satoh said:
I added hm_answernext, but the thickness is not changed.
I attach the files I tried, so please check them if you have time.
i was able to do it, changin the command to another one:
set tps 11.11
*readfile /BR_LAP52/ADRIANO/SUPORTES_2021/COMMUNITY/BAT_HMBATCH/changethicknesstest.hm
#*setvalue props name="PSHELL BATCHTEST" thickness=$tps
*attributeupdatedouble properties 1 95 1 1 1 $tps
hm_answernext yes
*writefile /BR_LAP52/ADRIANO/SUPORTES_2021/COMMUNITY/BAT_HMBATCH/changethicknesstest.hm 0i don't know what is wrong with *setvalue, but using *attibuteupdatedoube works.
1
Answers
-
i'm guessing if when you load HM, it is using the correct user profile (OptiStruct?)
Maybe dataname/code 95 is only for OptiStruct? I don't remember.
try using this one, instead, as it is solver-independent:
*setvalue props id=1108 thickness=5.55
0 -
Adriano A. Koga_21884 said:
i'm guessing if when you load HM, it is using the correct user profile (OptiStruct?)
Maybe dataname/code 95 is only for OptiStruct? I don't remember.
try using this one, instead, as it is solver-independent:
*setvalue props id=1108 thickness=5.55
Thank you for replying.
The command *setvalue~~ is obtained from command.tcl, so I don't know why thickness is described as 95 too. By the way, the solver I use is OptiStruct.
I tried your suggestion right away. The bat file works without error, but the thickness is not changed. However, when the tcl file is run from GUI, the thickness is changed normally.
0 -
Satoh said:
Thank you for replying.
The command *setvalue~~ is obtained from command.tcl, so I don't know why thickness is described as 95 too. By the way, the solver I use is OptiStruct.
I tried your suggestion right away. The bat file works without error, but the thickness is not changed. However, when the tcl file is run from GUI, the thickness is changed normally.
i didn`t look the script in details, but are you sure your file is being loaded correctly?
because you`re using relative path for your .hm file, and you assume that the current directory is correct.
I would double check this.
0 -
Adriano A. Koga_21884 said:
i didn`t look the script in details, but are you sure your file is being loaded correctly?
because you`re using relative path for your .hm file, and you assume that the current directory is correct.
I would double check this.
I apologize for confusing. I omitted the file path because it includes some information, but I use the absolute path in the actual tcl file and the scripts are all I describe here.
0 -
Satoh said:
I apologize for confusing. I omitted the file path because it includes some information, but I use the absolute path in the actual tcl file and the scripts are all I describe here.
what about removing the STATUS=1? does it change anything?
0 -
Adriano A. Koga_21884 said:
what about removing the STATUS=1? does it change anything?
I tried removing it below, but it does not change.
*setvalue props name="PSHELL BATCHTEST" thickness=$tps
When the same tcl file is run on GUI, the thickness is changed.
0 -
Satoh said:
I tried removing it below, but it does not change.
*setvalue props name="PSHELL BATCHTEST" thickness=$tps
When the same tcl file is run on GUI, the thickness is changed.
another thing to check.
When using *writefile are you combining it with answernext command?
Cause you're using the same file name, then you should provide a 'yes' for overwritting the existing file.
hm_answernext yes *writefile C:/mymodel.hm 0
0 -
Adriano A. Koga_21884 said:
another thing to check.
When using *writefile are you combining it with answernext command?
Cause you're using the same file name, then you should provide a 'yes' for overwritting the existing file.
hm_answernext yes *writefile C:/mymodel.hm 0
I added hm_answernext, but the thickness is not changed.
I attach the files I tried, so please check them if you have time.
0 -
Satoh said:
I added hm_answernext, but the thickness is not changed.
I attach the files I tried, so please check them if you have time.
i was able to do it, changin the command to another one:
set tps 11.11
*readfile /BR_LAP52/ADRIANO/SUPORTES_2021/COMMUNITY/BAT_HMBATCH/changethicknesstest.hm
#*setvalue props name="PSHELL BATCHTEST" thickness=$tps
*attributeupdatedouble properties 1 95 1 1 1 $tps
hm_answernext yes
*writefile /BR_LAP52/ADRIANO/SUPORTES_2021/COMMUNITY/BAT_HMBATCH/changethicknesstest.hm 0i don't know what is wrong with *setvalue, but using *attibuteupdatedoube works.
1 -
Adriano A. Koga_21884 said:
i was able to do it, changin the command to another one:
set tps 11.11
*readfile /BR_LAP52/ADRIANO/SUPORTES_2021/COMMUNITY/BAT_HMBATCH/changethicknesstest.hm
#*setvalue props name="PSHELL BATCHTEST" thickness=$tps
*attributeupdatedouble properties 1 95 1 1 1 $tps
hm_answernext yes
*writefile /BR_LAP52/ADRIANO/SUPORTES_2021/COMMUNITY/BAT_HMBATCH/changethicknesstest.hm 0i don't know what is wrong with *setvalue, but using *attibuteupdatedoube works.
I did it! Thank you so much!
0 -
Satoh said:
I did it! Thank you so much!
just adding a note, the disadvantage of this command is that it needs the ID of the property instead of its name. so just be careful if the ID isn`t #1.
1