How can I make this script work ?

Altair Community Member
Updated by unknown
Hello,
I found this script and I was trying to use it in order to separate each surface (that are in a single component) into a different new component.
*createmark surfs 1 displayed
foreach SurfId [hm_getmark surfs 1] {
set CompName [hm_getentityvalue surfs $SurfId collector.name 1]
*collectorcreateonly comps ${CompName}_$SurfId '' [expr round(rand()*63)+1]
*createmark surfs 1 $SurfId
*movemark surfs 1 ${CompName}_$SurfId }
But it's giving me this error "Collector specified not found in model" when trying to excecute line 3 I think.
Does anyone know what's wrong ?
Thank you for your help.
Sort by:
1 - 1 of
11
Sort by:
1 - 1 of
11

New Altair Community Member
Accepted Answer
Updated by Brett Ramsey_20633
There are commands that the command file uses that are referred to as deprecated. The list of these can be found here https://2021.help.altair.com/2021.1/hwdesktop/hwd/topics/reference/hm/deprecated_tcl_modify_commands.htm
*createmark surfs 1 displayed
foreach SurfId [hm_getmark surfs 1] {
set CompName [hm_getvalue surfs id=$SurfId dataname=collector.name]
*createentity comps name=${CompName}_${SurfId}
*createmark surfs 1 $SurfId
*movemark surfs 1 ${CompName}_$SurfId }
This should do the trick. I was not sure why you had the expr in there, so I removed it.
Hope this helps
There are commands that the command file uses that are referred to as deprecated. The list of these can be found here https://2021.help.altair.com/2021.1/hwdesktop/hwd/topics/reference/hm/deprecated_tcl_modify_commands.htm
*createmark surfs 1 displayed
foreach SurfId [hm_getmark surfs 1] {
set CompName [hm_getvalue surfs id=$SurfId dataname=collector.name]
*createentity comps name=${CompName}_${SurfId}
*createmark surfs 1 $SurfId
*movemark surfs 1 ${CompName}_$SurfId }
This should do the trick. I was not sure why you had the expr in there, so I removed it.
Hope this helps