Project - 2 - Generating the report for hypermesh file
Objective:
To create a report which contains the basic information about the model in .csv format
Problem Statement:
It is important to check the quality criteria of the model and prepare a report with all the check list. The modelers must perform this for all the model, and it consumes a lot of time.
To reduce the time in preparing the report, a script was written with reads the basic information about the model and check the elemental quality and reports the number of failed elements in a file.
Procedure to use the script:
Running the ‘Project2- Generating the report for Hypermesh File.tcl’ file will create a file named hm_report.csv in documents. This file will contain the information as shown in the image

TCL Script Explanation:
The following commands were used to get the required information
hm_info currentfile - to get the file name
$env(username) – to get the user name
[clock format [clock seconds] -format %T] – to get time
[clock format [clock seconds] -format %D] – to get date
hm_info templatetype – to get the current template
*EntityPreviewEmpty – to get empty components in the model
*EntityPreviewUnused – to get the unused properties and materials in the model
*elementtestlength – to test the length of the elements
*elementtestwarpage – to test the warpage of the elements
*elementtestaspect – to test the aspect ratio of the elements
*elementtestskew – to test the skewness of the elements
*elementtestjacobian – to test the jacobian of the elements
*elementtestduplicates – to test the duplicate elements
*elementtestinterangle – to test the interior angle of the quad and tria elements
After collecting the required data these were formatted and written in a file
Code:
# file name
set file_path [hm_info currentfile]
set file_name [string range $file_path [expr [string last "/" $file_path] +1] [string length $file_path]]
# User name, date, time, Profile/deck,
set info(user_name) $env(USERNAME)
set info(time) [clock format [clock seconds] -format %T]
set info(date) [clock format [clock seconds] -format %D]
set info(user_profile) [hm_info templatetype]
# count of component, prop, material, elements, nodes
*clearmark all 1; *clearmark all 2
set entity_type {"components" "properties" "materials" "elements" "nodes"}
foreach i $entity_type {
*createmark $i 1 "all"
set count($i) [hm_marklength $i 1]
}
# Count of empty comp/prop/mats
*clearmark all 1; *clearmark all 2
*EntityPreviewEmpty comps 1
set empty_comp [hm_marklength comps 1]
*EntityPreviewUnused props 1
set unused_prop [hm_marklength props 1]
*EntityPreviewUnused mats 1
set unused_mats [hm_marklength mats 1]
# Quality check
proc elem_quality {criteria range element_type} {
*clearmark all 1; *clearmark all 2
*createmark elems 1 "all"
if {[hm_marklength elems 1] != 0} {
switch $criteria {
length { if {$range == 1} {*elementtest$criteria elems 1 $::min_value 2 $range 2 0; set ::min_fail [hm_marklength elems 2]}
if {$range == 0} {*elementtest$criteria elems 1 $::max_value 2 $range 2 0; set ::max_fail [hm_marklength elems 2]}
}
interangle { if {$element_type == 1 && $range == 1} {*elementtest$criteria elems 1 $::tmin_value $element_type 2 $range 2 0; set ::tmin_fail [hm_marklength elems 2]}
if {$element_type == 1 && $range == 0} {*elementtest$criteria elems 1 $::tmax_value $element_type 2 $range 2 0; set ::tmax_fail [hm_marklength elems 2]}
if {$element_type == 0 && $range == 1} {*elementtest$criteria elems 1 $::qmin_value $element_type 2 $range 2 0; set ::qmin_fail [hm_marklength elems 2]}
if {$element_type == 0 && $range == 0} {*elementtest$criteria elems 1 $::qmax_value $element_type 2 $range 2 0; set ::qmax_fail [hm_marklength elems 2]}
}
warpage {*elementtest$criteria elems 1 $::w_value 2 2 0; set ::w_fail [hm_marklength elems 2]}
aspect {*elementtest$criteria elems 1 $::ar_value 2 2 0; set ::ar_fail [hm_marklength elems 2]}
skew {*elementtest$criteria elems 1 $::s_value 2 2 0; set ::s_fail [hm_marklength elems 2]}
jacobian {*elementtest$criteria elems 1 $::j_value 2 2 0; set ::j_fail [hm_marklength elems 2]}
duplicates {*elementtest$criteria elems 1 2 2; set ::dup_fail [hm_marklength elems 2]}
}
}
}
foreach x {::min_value ::max_value ::w_value ::ar_value ::s_value ::j_value ::tmin_value ::tmax_value ::qmin_value ::qmax_value} \
y {3 10 5 5 50 0.7 35 90 60 135} {
set $x $y
}
foreach x {::min_fail ::max_fail ::w_fail ::ar_fail ::s_fail ::j_fail ::tmin_fail ::tmax_fail ::qmin_fail ::qmax_fail ::dup_fail} {
set $x 0
}
foreach criteria {"length" "length" "warpage" "aspect" "skew" "jacobian" "interangle" "interangle" "interangle" "interangle" "duplicates"} \
range {1 0 0 0 0 0 1 0 1 0 0} \
type {0 0 0 0 0 0 1 1 0 0 0} {
elem_quality $criteria $range $type
}
set file [open hm_report.csv w]
puts $file [format %s%45s "\n\n" "$file_name - Model Report"]
puts $file [format %s%s%s%28s%s "\n\n" "user name :" " $info(user_name)" "date :" " $info(date)"]
puts $file [format %s%s%30s%s "user profile :" " $info(user_profile)" "time :" " $info(time)"]
puts $file "\n\n"
foreach j $entity_type {
puts $file [format %30s%s "Number of $j ...." " $count($j)"]
}
puts $file ""
puts $file [format %32s "No of empty components .... $empty_comp"]
puts $file [format %32s "No of unused properties .... $unused_prop"]
puts $file [format %32s "No of unused materials .... $unused_mats"]
puts $file [format %s%24s%13s "\n" "criteria" "# fail"]
foreach check {"min length" "max length" "warpage" "aspect" "skew" "jacobian" "tria min angle" "tria max angle" "quad min angle" "quad max angle" "duplicate elements"} \
fail "$::min_fail $::max_fail $::w_fail $::ar_fail $::s_fail $::j_fail $::tmin_fail $::tmax_fail $::qmin_fail $::qmax_fail $::dup_fail" {
puts $file [format %30s%2s "$check ...." " $fail"]
}
close $file
puts "done"
Conclusion:
A code was written to present basic information and element quality of the model in a file.