Code: Select all
for MaterialObject in self.MaterialObjects:
# get material properties
YM = FreeCAD.Units.Quantity(MaterialObject['Object'].Material['Mechanical_youngsmodulus'])
if YM.Unit.Type == '':
print 'Material "Mechanical_youngsmodulus" has no Unit, asuming kPa!' <-- assuming kPa...
YM = FreeCAD.Units.Quantity(YM.Value, FreeCAD.Units.Unit('Pa')) <-- but setting Pa. What's the reason?
else:
print 'YM unit: ', YM.Unit.Type <-- this prints "YM Unit: Pressure", not very useful
print 'YM = ', YM <-- this prints "YM = 2e+08 kg/mm*s^2", again the units are not useful
PR = float(MaterialObject['Object'].Material['FEM_poissonratio'])
print 'PR = ', PR
# write material properties
inpfile.write('*MATERIAL, NAME=' + MaterialObject['Object'].Material['General_name'] + '\n')
inpfile.write('*ELASTIC \n')
inpfile.write('{0:.3f}, '.format(YM.Value * 1E-3)) <-- this conversion by 1/000 is unit independent, so if the YM unit is not kPa it will produce something else not expected MPa
[1] https://github.com/FreeCAD/FreeCAD_sf_m ... is.py#L498