RENAMING COMP COLLECTORS IN HYPERMESH using TCL scripts

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

Hi All,

 

Anyone can tell me the How to Rename the comp collectors in HyperMesh using TCL scripts.

 

For suppose Comp name : ABC12345_2.00T  and  PID : 1  OUTPUT : ABC12345_1

 

i want to keep that first eight digits, and i want to delete that thickness information and i want to rename with its PID

 

please tell me If anyone know

 

Regards,

Sudhakar

 

 

 

 

Tagged:

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited December 2014

    Here is my not-yet-tested code:


    proc make_new_name { name } {
    # do some thing over current name to create new one
    return $newname;
    }
    *createmarkpanel components 1 'Select compo'
    set listComp [ hm_getmark components 1 0 ]
    foreach compID $listComp {
    set name [hm_entityinfo name components $compID]
    set newName [make_new_name $name]
    eval *renamecollector components $name $newName;
    }

  • tinh
    tinh Altair Community Member
    edited December 2014

    Hi

    below is a sample of 'make_new_name':


    proc make_new_name {name} {
    set i 1
    set _new_name [string range $name 0 [string last '_' $name]]
    set new_name ${_new_name}$i
    while {[hm_entityinfo exist comps $new_name]} {set new_name ${_new_name}[incr i]}
    set new_name
    }
  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited December 2014

    hi  Q.NGUYEN-DAI,

     

    Thanks for your support.

     

    but i didn't get exactly '# do some thing over current name to create new one'

     

    what it means.

     

    Regards,

    Sudhakar

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited December 2014

    Hi Tinh,

     

    Thanks  for your support,

     

    But Above what you mentioned TCL code not running.

     

    Regards,

    Sudhakar

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited December 2014

    hi  Q.NGUYEN-DAI,

     

    Thanks for your support.

     

    but i didn't get exactly '# do some thing over current name to create new one'

     

    what it means.

     

    Regards,

    Sudhakar

     

    Do you have some programming skill with TCL ?

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited December 2014

    Do you have some programming skill with TCL ?

     

    I have very basic Knowledge.

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited December 2014

    Hi Tinh,

     

    Thanks  for your valuable support,

     

    using your TCL code i prepared tcl script to rename all the collectors.

     

    Thanks,

    Sudhakar Donepudi

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited May 2015

    hi Sudhakar,

     

    What changes you made to the script provided by Tinh?

     

    If possible can you paste the complete TCL script you used

  • tinh
    tinh Altair Community Member
    edited May 2015

    hi Sudhakar,

     

    What changes you made to the script provided by Tinh?

     

    If possible can you paste the complete TCL script you used

    Hi, 

    you can use this function

    proc make_new_name {name} {set i 0set name_ [string range $name 0 [string last '_' $name]]while {[hm_entityinfo exist comps '${name_}[incr i]' -byname]} {}return ${name_}$i}
  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited October 2018

     

     

     

    Do you have some programming skill with TCL ?

    no i need to learn

     

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited October 2018

    How to rename the components by thicknesswise by using script? please help me out.

  • tinh
    tinh Altair Community Member
    edited October 2018

    Hi,

    try this

    foreach compname [hm_entitylist comps name] {

         *renamecollector comps $compname $compname_[hm_getthickness [hm_getentityvalue comps $compname id 0 -byname]]

    }

     

     

    and above 'proc make_new_name' is unneccessary, use hm_getincrementalname instead.