Import from excel

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

Hello all,

I have a list of coordinate point of coil spring model in excel.

Is there a possibility to import this point coordinate information to Hypermesh so that nodes as well as lines can be generated ? Using tcl command maybe? or notepad files?

Thank you very much in advance.

Tagged:

Answers

  • tinh
    tinh Altair Community Member
    edited July 2012

    Hi there,

    it's a very simple tcl code,

    like this ex.

    your excel file ==> Save as... CSV format:

    xCoord,yCoord,zCoord

    0,0,0

    1,1,0.5

    1.4,1.4,1.0

    ...

    tcl file:

    #read the csv file

    set csvfile [open csvfilename.csv r]

    set NodeList {}

    while {![eof $csvfile]} {

    gets $csvfile line

    set NodeCoords [split $line ,]

    #create the nodes

    if {![catch {eval *createnode $NodeCoords 0}]} {lappend NodeList [hm_entitymaxid nodes]}

    }

    close $csvfile

    #create sprial

    eval *createlist nodes 1 $NodeList

    *linecreatefromnodes 1 2 150 5 179

    ############

    I usually write tcl codes like those

    If you need my help, don't hersitate

    image/emoticons/default_biggrin.png' alt=':D' srcset='/emoticons/biggrin@2x.png 2x' width='20' height='20'>

    rgds,

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited February 2018

    @Tinh: Hello, I have almost similar issue.

    I have an excel file (.csv format).I need to retrieve the data in my first column as a list.

     

    I placed my csv file in my TCL script folder and tried your above TCL script i.e.

     

    'set csvfile [open MaterialData Al6063 - Copy.csv r]'

     

     

    'Tcl script error (Tcl/Tk Script) : wrong # args: should be 'open
                  fileName ?access? ?permissions?'                                 
                  while executing                                                  
                  'open MaterialData Al6063 - Copy.csv r'                          
                  invoked from within                                              
                  'set csvfile [open MaterialData Al6063 - Copy.csv r]'            
                  (file 'D:/RWTH/Mini thesis/V6/TCL V4/Untitled3.tcl' line 6)      
                  invoked from within                                              
                  'source {D:/RWTH/Mini thesis/V6/TCL V4/Untitled3.tcl}'           
                  ('uplevel' body line 1)                                          
                  invoked from within                                              
                  '# Compiled -- no source code available                          
                  error 'called a copy of a compiled script''                      
                  (procedure '::hw::RunTclTkScpt' line 1)                          
                  invoked from within                                              
                  '::hw::RunTclTkScpt 219' '

     

    I would be really glad,if you can look at the above issue and reply.

  • tinh
    tinh Altair Community Member
    edited February 2018

    Hi,

    it should be :

    set csvfile [open 'MaterialData Al6063 - Copy.csv' r]

    because your file name has space