Generating report for hypermesh file by using the tcl macro
By using tcl we will generate an industry-standard report
set f [open "test3.csv" w]
set systemTime [clock seconds]
puts $f "Username,$env(username)"
puts $f "Time, [clock format $systemTime -format %H:%M:%S]"
puts $f "Date, [clock format $systemTime -format {%A the %d of %B %Y}]"
puts $f "Solver profile,[hm_getsolver]"
puts $f "comp id,comp name,thickness,Material name,Property name, element count,surface count"
*createmark comps 1 "all"
set all_comp_id [hm_getmark comps 1]
set property {}
set material {}
set empty_comp_id {}
foreach a $all_comp_id {
puts $a
set comp_name [hm_entityinfo name comps $a]
set thick [hm_getthickness comps $a]
set prop_name [hm_getvalue comps id=$a dataname=property.name]
set prop_number [hm_getentityvalue comps $a "property.id" 0 -byid]
if {$prop_number==0} {
set mat_name "empty"
} else {
set mat_name [hm_getvalue props id=$prop_number dataname=material.name]
}
*createmark elems 2 "by comp id" $a
set b [hm_getmark elems 2]
set no_elem [llength $b]
*createmark surfaces 2 "by comp id" $a
set b [hm_getmark surfs 2]
set no_surf [llength $b]
puts $f "$a,$comp_name,$thick,$mat_name,$prop_name,$no_elem,$no_surf"
lappend property $prop_name
lappend material $mat_name
if {$no_elem==$no_surf} {
lappend empty_comp_id $comp_name
}
}
puts $f "t"
puts $f "Empty component list"
foreach a $empty_comp_id {
puts $f $a
}
puts $f "t"
puts $f "Empty Material list"
puts $f "id, name"
*EntityPreviewUnused mats 1
set a [hm_getmark mats 1]
foreach id $a {
set d [hm_entityinfo name materials $id]
puts $f "$id,$d"
}
puts $f "t"
puts $f "Empty Property list"
puts $f "id, name"
*EntityPreviewUnused props 1
set a [hm_getmark props 1]
foreach id $a {
set d [hm_entityinfo name props $id]
puts $f "$id,$d"
}
*createmark elems 1 "by config" quad4 quad8
set a [hm_marklength elems 1]
*createmark elems 1 "by config" tria3 tria6
set b [hm_marklength elems 1]
puts $f "t"
puts $f "Quad element, $a"
puts $f "Tria element, $b"
puts $f "t"
*createmark elems 1 "all"
set duplicates [hm_getduplicateelements 1 2 0]
set a [llength $duplicates]
puts $f "duplicate elemnt count, $a"
gets stdin d
*displayall
*createmark elements 1 "all"
*createmark elements 2
*elementtestlength elements 1 $d 2 0 2 0 " 2D Length > "
*maskentitymark elems 2
*maskreverse elems
*createmark elems 1 "displayed"
set Max [hm_marklength elems 1]
puts $f "t"
puts $f "Quality Criteria"
puts $f "Max length,$d,$Max"
gets stdin d1
*displayall
*createmark elements 1 "all"
*createmark elements 2
*elementtestlength elements 1 $d1 2 1 2 0 " 2D Length < "
*maskentitymark elems 2
*maskreverse elems
*createmark elems 1 "displayed"
set Min [hm_marklength elems 1]
puts $f "Min length,$d1,$Min"
gets stdin d1
*displayall
*createmark elements 1 "all"
*createmark elements 2
*elementtestaspect elements 1 $d1 2 2 0 " 2D Aspect Ratio "
*maskentitymark elems 2
*maskreverse elems
*createmark elems 1 "displayed"
set Min [hm_marklength elems 1]
puts $f "Aspect Ratio,$d1,$Min"
close $f