HM Script to write out seperate *.stl file for each component
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
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
It's not so complicated. Here're some ideas:
The following command disables output for component ID=5:
*setvalue comps id=5 outputsuppressed=1Example 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
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
It's not so complicated. Here're some ideas:
The following command disables output for component ID=5:
Example of STL export: