working on material framework

This commit is contained in:
jriegel
2013-06-06 23:24:30 +02:00
parent cbcbf831b9
commit bc9a63540d
3 changed files with 96 additions and 7 deletions

View File

@@ -21,8 +21,78 @@
#***************************************************************************
import FreeCAD
# here the usage description if you use this tool from the command line ("__main__")
CommandlineUsage = """Material - Tool to work with FreeCAD Material definition cards
Usage:
Material [Options] card-file-name
Options:
-c, --output-csv=file-name write a comma seperated grid with the material data
Exit:
0 No Error or Warning found
1 Argument error, wrong or less Arguments given
Tool to work with FreeCAD Material definition cards
Examples:
Material "StandardMaterial/Steel.FCMat"
Autor:
(c) 2013 Juergen Riegel
mail@juergen-riegel.net
Licence: LGPL
Version:
0.1
"""
def importFCMat(fileName):
FreeCAD.Console.PrintMsg(fileName)
import ConfigParser
Config = ConfigParser.ConfigParser()
Config.read(fileName)
dict1 = {}
for section in Config.sections():
options = Config.options(section)
for option in options:
dict1[section+'_'+option] = Config.get(section, option)
return dict1
if __name__ == '__main__':
import sys, getopt
try:
opts, args = getopt.getopt(sys.argv[1:], "c:", ["output-csv="])
except getopt.GetoptError:
# print help information and exit:
sys.stderr.write(CommandlineUsage)
sys.exit(1)
# checking on the options
for o, a in opts:
if o in ("-c", "--output-csv"):
print "writing file: " + a +"\n"
OutPath = a
# runing through the files
FileName = args[0]
kv_map = importFCMat(FileName)
for k in kv_map.keys():
print `k` + " : " + `kv_map[k]`
sys.exit(0) # no error

View File

@@ -6,7 +6,7 @@ To make the material description usefull for a lot of application only files wit
will be accepted into the FreeCAD source distribution. For more detail about the license see here:
http://creativecommons.org/
Pleas help!
Please help!
Enlargen the base of Materials for FreeCAD will greatly benefit the usability of FreeCAD. So please
help us to add new Materials, review existing ones or add additional vlaues.

View File

@@ -1,13 +1,32 @@
; Standard Steel Material
; (c) Juergen Riegel 2013 (CC-BY 3.0)
; (c) 2013 Juergen Riegel (CC-BY 3.0)
; information about the content of such cards you can find here:
; http://www.freecadweb.org/wiki/index.php?title=Material
[General]
; General name, need to be the same as the file name
Name=Steel
; Father of steel is metal
Father=Metal
; more elaborate description of this material card:
Description: This is a blend Steel material card. The values are at the low end of the spectrum. If you need a more precise material definition use the more specialised steel cards.
; Specific wight in kg/mm^3
SpecificWeight=7800.0e-12
; No special Vendor
Vendor:
; For blend materials the wikipedia page is a good source of information:
ProductURL=http://en.wikipedia.org/wiki/Steel
; for blends a rough estimation
SpecificPrice= 1,5 Euro/Kg
[Mechanical]
; youngs modulus (or E-Module) in mPa (source: http://en.wikipedia.org/wiki/Young%27s_modulus)
YoungsModulus=200.0e12
YoungsModulus=200.0e12
; http://en.wikipedia.org/wiki/Ultimate_tensile_strength
UltimateTensileStrength=
; http://en.wikipedia.org/wiki/Compressive_strength
CompressiveStrength=
; http://en.wikipedia.org/wiki/Elasticity_%28physics%29
Elasticity=
; http://en.wikipedia.org/wiki/Fracture_toughness
FractureToughness: