tcl to excel

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

Hi all,

Can we write tcl variables to a excel file.

 

Thanks ,

Mahes

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited September 2017

    Hi Mahes,

    Can you please elaborate on this, what variables are you trying to export as csv?

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited September 2017

    Hi George,

    for example I have a comp id 1

    I wanna get the info about the component and write to a excel file.

     

     

    Thanks,

    Mahes

  • tinh
    tinh Altair Community Member
    edited September 2017

    Hi

    Switch model browser to 'component view' mode, right click on browser and select 'export' to csv file

     

    Or, in utility tab, click 'component table' and select File > export to csv file

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited September 2017

    Hi tinh

    I need to do in macro...the above thing is just a example.

     

     

     

    Thanks,

    Mahes

  • tinh
    tinh Altair Community Member
    edited September 2017

    Ok it is like this

    set fpt [open c:/sample.csv w]

    fconfigure $fpt -encoding uft-8

    puts $fpt 'comp id,comp name,thickness'

    foreach compid {1 2 3 4 5} {

    puts $fpt '$compid,[hm_getentityvalue comps $compid name 1 -byid],[hm_getthickness comps $compid]'

    }

    close $fpt

     

    You should use csv package with commands ::csv::join and ::csv::split to handle strings with special characters

     

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited September 2017

    Ok it is like this

    set fpt [open c:/sample.csv w]

    fconfigure $fpt -encoding uft-8

    puts $fpt 'comp id,comp name,thickness'

    foreach compid {1 2 3 4 5} {

    puts $fpt '$compid,[hm_getentityvalue comps $compid name 1 -byid],[hm_getthickness comps $compid]'

    }

    close $fpt

     

    You should use csv package with commands ::csv::join and ::csv::split to handle strings with special characters

     

    Thanks tinh.

    I will try thiz champ

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited September 2017

    Hi tinh,

    @tinh

    for using fconfigure , uft  is there any package I need to import

     

     

     

    Thanks,

    mahes

  • tinh
    tinh Altair Community Member
    edited September 2017

    No, you don't.

    it is for case you have unicode characters in data, example compnáme

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited September 2017

    Thanks tinh..