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