set lst_comp [hm_entitylist comps name]
set tmpl "[hm_info -appinfo SPECIFIEDPATH TEMPLATES_DIR]/feoutput/nastran/general"
set savedir "https://www.gofarlic.com/work/Temp/Hm"
*displaynone
foreach comp_name $lst_comp {
*displaycollectorwithfilter components "on" $comp_name 1 0
*retainmarkselections 0
*entityhighlighting 1
*createstringarray 0
*feoutputwithdata $tmpl $savedir/$comp_name.bdf 0 0 0 1 0
*displaycollectorwithfilter components "off" $comp_name 1 0
}
*displayall
*createmark comps 1 all
set mycomps [ hm_getmark comps 1 ]
*clearmark comps 1
set NumFail 0
set hmname [hm_info hmfilename]
set Errorlog [file join [file dirname $hmname] "error.log"]
set fid [open $Errorlog w]
puts $fid "The file is generated by Midsurface."
foreach Compid $mycomps {
set Compname [hm_getcollectorname comps $Compid]
hm_createmark solids 1 "by component" $Compname
set SolidIds [hm_getmark solids 1]
set NumSolids [llength $SolidIds]
puts "$Compname has $NumSolids solids "
if {$NumSolids < 1} {
incr NumFail
puts -nonewline $fid $NumFail
puts -nonewline $fid ". "
puts -nonewline $fid "\["
puts -nonewline $fid $Compname
puts -nonewline $fid "\] "
puts $fid ", Failure=No Solid in $Compname."
continue
}
*retainmarkselections 1
*setsurfacenormalsdisplaytype 1
*normalsoff
*midsurface_extract_10 solids 1 3 0 1 1 0 0 20 0 0 10 0 10 -2 undefined 0 0 1
*midsurface_remove_edit_bodies
*release_temp_fixed_vertices
*normalsoff
set suffix [hm_getfloat "Thickness of component $Compname:"]
set divchar "_"
set lenunit "mm"
set Newcompname $Compname$divchar$suffix$lenunit
if { [hm_entityinfo exist comps $Newcompname -byname] == 1 } {
hm_errormessage "Component name $Newcompname already exists."
puts $fid "Component name $Newcompname already exists."
return
}
*renamecollector components "Middle Surface" $Newcompname
*retainmarkselections 0
}
close $fid
hm_usermessage "Done."
微信关注【有限元微刊】,获得更多神技~
