@@ -74,21 +74,39 @@ def __init__(self, obj = None, prop = None, material = None):
74
74
self .updateContents (d )
75
75
76
76
77
+ def getMaterialResources (self ):
78
+ self .fem_prefs = FreeCAD .ParamGet ("User parameter:BaseApp/Preferences/Mod/Material/Resources" )
79
+ use_built_in_materials = self .fem_prefs .GetBool ("UseBuiltInMaterials" , True )
80
+ use_mat_from_config_dir = self .fem_prefs .GetBool ("UseMaterialsFromConfigDir" , True )
81
+ use_mat_from_custom_dir = self .fem_prefs .GetBool ("UseMaterialsFromCustomDir" , True )
82
+ if use_mat_from_custom_dir :
83
+ custom_mat_dir = self .fem_prefs .GetString ("CustomMaterialsDir" , "" )
84
+ # later found cards with same name will override cards
85
+ # FreeCAD returns paths with / at the end, thus not os.sep is needed on first +
86
+ self .resources = []
87
+ if use_built_in_materials :
88
+ self .resources .append (FreeCAD .getResourceDir () + "Mod" + os .sep + "Material" + os .sep + "StandardMaterial" )
89
+ if use_mat_from_config_dir :
90
+ self .resources .append (FreeCAD .ConfigGet ("UserAppData" ) + "Material" )
91
+ if use_mat_from_custom_dir :
92
+ custom_mat_dir = self .fem_prefs .GetString ("CustomMaterialsDir" , "" )
93
+ if os .path .exists (custom_mat_dir ):
94
+ self .resources .append (custom_mat_dir )
95
+ self .outputResources ()
96
+
97
+
98
+ def outputResources (self ):
99
+ print ('locations we gone look for material cards:' )
100
+ for path in self .resources :
101
+ print (' ' + path )
102
+ print ('\n ' )
103
+
104
+
77
105
def updateCards (self ):
78
106
"updates the contents of the materials combo with existing material cards"
79
- # look for cards in both resources dir and a Materials sub-folder in the user folder.
80
- # User cards with same name will override system cards
81
- # FreeCAD returns paths with / at the end, thus not os.sep is needed on first +
82
- paths = [FreeCAD .getResourceDir () + "Mod" + os .sep + "Material" + os .sep + "StandardMaterial" ]
83
- ap = FreeCAD .ConfigGet ("UserAppData" ) + "Material"
84
- if os .path .exists (ap ):
85
- paths .append (ap )
86
- # print('locations we gone look for material cards:')
87
- # for path in paths:
88
- # print(' ' + path)
89
- # print('\n')
107
+ self .getMaterialResources ()
90
108
self .cards = {}
91
- for p in paths :
109
+ for p in self . resources :
92
110
for f in os .listdir (p ):
93
111
b ,e = os .path .splitext (f )
94
112
if e .upper () == ".FCMAT" :
0 commit comments