🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

HM Script to write out seperate *.stl file for each component

JeyUser: "Jey"
Altair Community Member
Updated by Jey

Hello,

I have 150 list of components ( one comp per comp collector) in hypermesh. Need to write out seperate *.stl file for each component with Component Collector name followed by Materialname and thickness

i.e Comp Name: Wheels, Material Name -Steel; Property Name - Wheel_Shell with Property values, E, V & Thickness = 3 mm.

Need to write filename of part: Wheels_Steel_3mm

If above said is complex, need script to write out with component name only.

Find more posts tagged with

Sort by:
1 - 4 of 41
    QuyNguyenDaiUser: "QuyNguyenDai"
    Altair Community Member
    Updated by QuyNguyenDai

    It's not so complicated. Here're some ideas:

     

    The following command disables output for component ID=5:

     *setvalue comps id=5 outputsuppressed=1

    Example of STL export:

     *createstringarray 2 'CONNECTORS_SKIP' 'HMMATCOMMENTS_XML' *feoutputwithdata 'C:/Program Files/Altair/2020/hwdesktop/templates/feoutput/misc/triasto.stl' 'C:/Users/Me/test1.stl' 0 0 2 1 2

     

     

    Try the attached script for your case.  Adapt it as needed.

     

    #get altair home directory
    set home_dir [hm_info -appinfo ALTAIR_HOME]
    #set output_folder {d:/Adriano/Macros}
    set output_folder [tk_chooseDirectory]

    #select components and store in a list
    *createmarkpanel comps 1 'Select components to export:'
    set comps_list [hm_getmark comps 1]
    *clearmark comps 1

    #foreach component in the list 
    foreach compo $comps_list {

        #isolate compo 
        *createmark components 2 $compo
        *createstringarray 2 'elements_on' 'geometry_off'
        *isolateonlyentitybymark 2 1 2
        
        #retrieve compo data
        set compname [hm_getvalue comps id=$compo dataname=name]
        set matname [hm_getvalue comps id=$compo dataname=property.material.name]
        set thick [hm_getvalue comps id=$compo dataname=thickness]
        set thick [format %2.2f $thick]
        set exportname '${compname}_${matname}_${thick}'

        #export model as STL
        *createstringarray 2 'CONNECTORS_SKIP' 'HMMATCOMMENTS_XML'
        *feoutputwithdata [file join $home_dir 'templates/feoutput/misc/triasto.stl'] [file join $output_folder '${exportname}.stl'] 0 0 0 1 2

    }
    #endforeach 

    Unable to find an attachment - read this blog

    JeyUser: "Jey"
    Altair Community Member
    OP
    Updated by Jey

    It's not so complicated. Here're some ideas:

     

    The following command disables output for component ID=5:

      *setvalue comps id=5 outputsuppressed=1

    Example of STL export:

      *createstringarray 2 'CONNECTORS_SKIP' 'HMMATCOMMENTS_XML' *feoutputwithdata 'C:/Program Files/Altair/2020/hwdesktop/templates/feoutput/misc/triasto.stl' 'C:/Users/Me/test1.stl' 0 0 2 1 2

     

     

    Thanks 

    JeyUser: "Jey"
    Altair Community Member
    OP
    Updated by Jey

    Try the attached script for your case.  Adapt it as needed.

     

    #get altair home directory
    set home_dir [hm_info -appinfo ALTAIR_HOME]
    #set output_folder {d:/Adriano/Macros}
    set output_folder [tk_chooseDirectory]

    #select components and store in a list
    *createmarkpanel comps 1 'Select components to export:'
    set comps_list [hm_getmark comps 1]
    *clearmark comps 1

    #foreach component in the list 
    foreach compo $comps_list {

        #isolate compo 
        *createmark components 2 $compo
        *createstringarray 2 'elements_on' 'geometry_off'
        *isolateonlyentitybymark 2 1 2
        
        #retrieve compo data
        set compname [hm_getvalue comps id=$compo dataname=name]
        set matname [hm_getvalue comps id=$compo dataname=property.material.name]
        set thick [hm_getvalue comps id=$compo dataname=thickness]
        set thick [format %2.2f $thick]
        set exportname '${compname}_${matname}_${thick}'

        #export model as STL
        *createstringarray 2 'CONNECTORS_SKIP' 'HMMATCOMMENTS_XML'
        *feoutputwithdata [file join $home_dir 'templates/feoutput/misc/triasto.stl'] [file join $output_folder '${exportname}.stl'] 0 0 0 1 2

    }
    #endforeach 

    Thanks

    Unable to find an attachment - read this blog