How to read the material properties of components with TCL
I want to create a text file with the volumes and material properties of all the components in my model.
I'm using this code to extract the volume:
*createmark solids 1 all set solid_list [hm_getmark solids 1] foreach solid $solid_list { *createmark solids 1 $solid set vol [hm_getvolumeofsolid solid $solid] puts '$vol' }
How can I extract the density (rho), modulus of elasticity (E), and Poisson's ratio (nu) from my components?
Thanks.
Answers
-
these material properties are related to your material, so you should extract them from your material data, according with your solver for some cases, using hm_getvalue. For these 3 listed in your case, it is possible to get them directly like this.
hm_getvalue materials id=$matid dataname=youngsmodulus
hm_getvalue materials id=$matid dataname=poissonsratio
hm_getvalue materials id=$matid dataname=density
Can you try it?
Or if you want to retrieve from the component, this might work (have to test this).
hm_getvalue components id=$compid dataname=material.youngsmodulus
0 -
/profile/49518-diesaen/?do=hovercard' data-mentionid='49518' href='<___base_url___>/profile/49518-diesaen/' rel=''>@diesaen: your sample code has nothing to see with FE entities., just the Geometry.
The material data is linked to elements via Property.
0 -
Thanks Adriano, that was what I needed to get it working as shown below:
*createmark comps 1 all set comps_list [hm_getmark comps 1] foreach comp $comps_list { *createmark comps 1 $comp set compname [hm_getcollectorname comps $comp] set matname [hm_getvalue components id=$comp dataname=material.name] set mat_id [hm_getvalue components id=$comp dataname=material] set moe [hm_getvalue materials id=$mat_id dataname=E] set nu [hm_getvalue materials id=$mat_id dataname=Rho] set rho [hm_getvalue materials id=$mat_id dataname=Nu] puts '$comp,$compname,$matname,$moe,$nu,$rho' }
Thanks
0