Is there a TCL/TK script available to export components as separate files ?

srinivas rallabandi_21059
srinivas rallabandi_21059 Altair Community Member
edited September 2022 in Community Q&A

I have a FEM model with different parts/collectors in hypermesh.

is there any tcl/tk available to export each collector as separate file with filename as collector name 

 

thank you 

Answers

  • Adriano A. Koga
    Adriano A. Koga
    Altair Employee
    edited September 2022

    you could build a script to do this, by performing the operations manually once, and then looking at the command.tcl files into your working directory and adding a few layers of TCL scripting on top of it.

     

    What format are you intending to export? Is it mesh? or geometry?

  • Adriano A. Koga
    Adriano A. Koga
    Altair Employee
    edited September 2022

    Try something like this

     

     

    #select and store the component id list for ALL
    *createmark comps 1 "all"
    set comps_list [hm_getmark comps 1]
    *clearmark comps 1
    #retrieve comps names for the list
    set compname_list [hm_getvalue comps user_ids=$comps_list dataname=name]

    #define output direcory >> needs to exist
    set output_dir {c:/temp}
    #retrieves the template export file from the installation
    set currenttemplate [hm_info templatefilename]

    #loop over all components
    foreach compo $comps_list compnamo $compname_list {

        #isolate each component
        *createmark components 2 $compo
        *createstringarray 2 "elements_on" "geometry_on"
        *isolateonlyentitybymark 2 1 2

        #export .fem file to the output dir, using the compnamo as base name
        *feoutputmergeincludefiles 0
        *setsubmodeltype "HM_INCLUDEFILES"
        *setentitytypesupportedbyenggid 1 0
        *createstringarray 7 "HM_NODEELEMS_SET_COMPRESS_SKIP " "EXPORT_DMIG_LONGFORMAT " "HMSUBSYSTEMCOMMENTS_XML" "HMMATCOMMENTS_XML" "HMBOMCOMMENTS_XML" "INCLUDE_RELATIVE_PATH " "EXPORT_LEGACY_COMP_COMMENTS "
        *feoutputwithdata "$currenttemplate" [file join $output_dir "${compnamo}.fem"] 0 0 0 1 7

    }

  • srinivas rallabandi_21059
    srinivas rallabandi_21059 Altair Community Member
    edited September 2022

    Hi Adriano

    Thank you so much for your Reply. Actually, i am Exporting in nastran/Aabqus Template. based on your initial reply i tried manually using command.cmf and creating a generic one.

     

    Let me go through your logic, thanks a gain 

     

    *displaycollectorwithfilter(components,"on","Part_01",1,0)
    *displaycollectorwithfilter(components,"on","part_02",1,0)
    *displaycollectorwithfilter(components,"on","Part_03",1,0)
    *window(0,0,0,0,0)
    *feoutput("C:/Program Files/Altair/2021.1/hwdesktop/templates/feoutput/nastran/general","E:\Split_files\Assembly_01.dat",1,0,0)
    *displaycollectorwithfilter(components,"none","",1,0)
    ///--------Export Systems-------//
    *displaycollectorwithfilter(systcols,"on","B1",1,0)
    *displaycollectorwithfilter(systcols,"on","B2",1,0)
    *displaycollectorwithfilter(systcols,"on","B3",1,0)
    *window(0,0,0,0,0)
    *feoutput("C:/Program Files/Altair/2021.1/hwdesktop/templates/feoutput/nastran/general","E:\Split_files\co-ordinate.dat",1,0,0)
    *displaycollectorwithfilter(systcols,"none","",1,0)
    *endmacro()
    ///--------Export lOADS-------//
    *displaycollectorwithfilter(loadcols,"on","External-loads",1,0)
    *window(0,0,0,0,0)
    *feoutput("C:/Program Files/Altair/2021.1/hwdesktop/templates/feoutput/nastran/general","E:\Split_files\External-loads.dat",1,0,0)
    *displaycollectorwithfilter(loadcols,"none","",1,0)