How can I make this script work ?

Unknown
edited February 2022 in Community Q&A
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.

Best Answer

  • Brett Ramsey_20633
    Brett Ramsey_20633 New Altair Community Member
    edited February 2022 Answer ✓

    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

Answers

  • Brett Ramsey_20633
    Brett Ramsey_20633 New Altair Community Member
    edited February 2022 Answer ✓

    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