#-----------------------------------------------------------------------------------------------------
# created by rajasekaran natarajan date unknown updated on 072006
#www.oocities.org/rajsekarann
#rajasekaran.natarajan <at> gmail.com
# Macro to display thickness and Material of the selected components in a message Box
# only thick or only material display is possible by commenting out some part
#-----------------------------------------------------------------------------------------------------

*createmarkpanel components 1 "Select components"

set compList [ hm_getmark components 1 ]
set msgBuff    "Componentname\t\t Thickness\n"    

if { ([llength $compList] == 0) } {

        
        hm_errormessage "No Components were selected: terminating."
        
        
        } else {

            foreach i $compList {
                set compthk [hm_getcompthickness $i]
                set matname [ hm_getentityvalue COMPS $i "material.name" 1 ]
                set matid [hm_getentityvalue MATERIALS $matname id 0]
                set matType [hm_attributeindexidentifier MATERIALS $matid 1]
    
                switch $matType {
                       146 {set matType MAT1 }
                       159 {set matType MAT2 }
                       195 {set matType MAT8 }
                       214 {set matType MAT9 }
                       99999999 {set matType "" }
                       default {set matType ""}
                }
                if {$matType == "MAT1"} {
                           set e [format "%2.4e" [hm_getentityvalue mats $matid "\$E" 0 -byid]]
                           set g [format "%2.4e" [hm_getentityvalue mats $matid "\$G" 0 -byid]]
                           set nu [format "%2.2f" [hm_getentityvalue mats $matid "\$Nu" 0 -byid]]
                           set rho [format "%2.4e" [hm_getentityvalue mats $matid "\$Rho" 0 -byid]]
                           set alpha [format "%2.2f" [hm_getentityvalue mats $matid "\$MAT1_A" 0 -byid]]
                           set tref [format "%2.2f" [hm_getentityvalue mats $matid "\$MAT1_TREF" 0 -byid]]
                }
    
                            
                set name [hm_getcollectorname comp $i]
                if {$matType == "MAT1"} {
                    append msgBuff "$name\t = \t $compthk\n\n\"$matname\" \t $matid\t $matType \n\nE\t= $e \nG\t= $g \nNu\t= $nu \nRho\t= $rho \nalpha\t= $alpha \nT_ref\t= $tref\n"
                } else {
                        append msgBuff "$name\t = \t $compthk\n\n\"$matname\" \t $matid\t $matType \n"
                }
            }
            tk_messageBox -message $msgBuff

                }