Some fixes in the Fem/Material interplay

This commit is contained in:
jriegel 2013-08-21 17:53:45 +02:00
parent 0285dfede9
commit 35d9459853
6 changed files with 50 additions and 21 deletions

View File

@ -88,7 +88,9 @@ class _CommandMechanicalJobControl:
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Analysis","Dialog to start the calculation of the machanical anlysis")}
def Activated(self):
taskd = _JobControlTaskPanel()
import FemGui
taskd = _JobControlTaskPanel(FemGui.getActiveAnalysis())
#taskd.obj = vobj.Object
taskd.update()
FreeCADGui.Control.showDialog(taskd)
@ -96,7 +98,8 @@ class _CommandMechanicalJobControl:
def IsActive(self):
import FemGui
return True
return FreeCADGui.ActiveDocument != None and FemGui.getActiveAnalysis() != None
class _FemAnalysis:
@ -163,13 +166,13 @@ class _ViewProviderFemAnalysis:
class _JobControlTaskPanel:
'''The editmode TaskPanel for Material objects'''
def __init__(self):
def __init__(self,object):
# the panel has a tree widget that contains categories
# for the subcomponents, such as additions, subtractions.
# the categories are shown only if they are not empty.
form_class, base_class = uic.loadUiType(FreeCAD.getHomePath() + "Mod/Fem/MechanicalAnalysis.ui")
#self.obj = object
self.obj = object
self.formUi = form_class()
self.form = QtGui.QWidget()
self.formUi.setupUi(self.form)

View File

@ -33,11 +33,7 @@ __title__="Machine-Distortion FemSetGeometryObject managment"
__author__ = "Juergen Riegel"
__url__ = "http://free-cad.sourceforge.net"
StartMat = {'General_name' :'Steel',
'Mechanical_youngsmodulus' :'7000.00',
'FEM_poissonratio' :'0.30',
}
def makeMechanicalMaterial(name):
'''makeMaterial(name): makes an Material
@ -66,8 +62,8 @@ class _CommandMechanicalMaterial:
FreeCAD.ActiveDocument.openTransaction("Create Material")
FreeCADGui.addModule("MechanicalMaterial")
FreeCADGui.doCommand("MechanicalMaterial.makeMechanicalMaterial('MechanicalMaterial')")
FreeCADGui.doCommand("App.activeDocument()."+FemGui.getActiveAnalysis().Name+".Member = App.activeDocument()."+FemGui.getActiveAnalysis().Name+".Member + [App.ActiveDocument.activeObject()]")
FreeCADGui.doCommand("Gui.activeDocument().setEdit(mat.Name,0)")
FreeCADGui.doCommand("App.activeDocument()."+FemGui.getActiveAnalysis().Name+".Member = App.activeDocument()."+FemGui.getActiveAnalysis().Name+".Member + [App.ActiveDocument.ActiveObject]")
FreeCADGui.doCommand("Gui.activeDocument().setEdit(App.ActiveDocument.ActiveObject.Name,0)")
#FreeCADGui.doCommand("Fem.makeMaterial()")
else:
FreeCADGui.doCommand("Gui.activeDocument().setEdit('"+MatObj.Name+"',0)")
@ -84,7 +80,7 @@ class _MechanicalMaterial:
def __init__(self,obj):
self.Type = "MechanicaltMaterial"
obj.Proxy = self
obj.Material = StartMat
#obj.Material = StartMat
def execute(self,obj):
@ -154,7 +150,7 @@ class _MechanicalMaterialTaskPanel:
matmap = self.obj.Material
matmap['Mechanical_youngsmodulus'] = str(self.formUi.spinBox_young_modulus.value())
matmap['Mechanical_youngsmodulus'] = str(self.formUi.spinBox_young_modulus.value() * 1e+6)
matmap['FEM_poissonratio'] = str(self.formUi.spinBox_poisson_ratio.value())
self.obj.Material = matmap
@ -165,8 +161,10 @@ class _MechanicalMaterialTaskPanel:
matmap = self.obj.Material
if matmap.has_key('Mechanical_youngsmodulus'):
self.formUi.spinBox_young_modulus.setValue(float(matmap['Mechanical_youngsmodulus']))
print float(matmap['Mechanical_youngsmodulus'])
self.formUi.spinBox_young_modulus.setValue(float(matmap['Mechanical_youngsmodulus'])/1e+6)
if matmap.has_key('FEM_poissonratio'):
print float(matmap['FEM_poissonratio'])
self.formUi.spinBox_poisson_ratio.setValue(float(matmap['FEM_poissonratio']))
def isAllowedAlterSelection(self):
@ -180,6 +178,8 @@ class _MechanicalMaterialTaskPanel:
def update(self):
'fills the widgets'
self.formUi.spinBox_young_modulus.setValue(0.0)
self.formUi.spinBox_poisson_ratio.setValue(0.0)
self.transferFrom()
self.fillMaterialCombo()
@ -218,10 +218,14 @@ class _MechanicalMaterialTaskPanel:
def fillMaterialCombo(self):
import glob,os
matmap = self.obj.Material
dirname = FreeCAD.ConfigGet("AppHomePath")+"data/Mod/Material/StandardMaterial"
self.pathList = glob.glob(dirname + '/*.FCMat')
self.formUi.comboBox_MaterialsInDir.clear()
self.formUi.comboBox_MaterialsInDir.addItem('-> choose Material')
if(matmap.has_key('General_name')):
self.formUi.comboBox_MaterialsInDir.addItem(matmap['General_name'])
else:
self.formUi.comboBox_MaterialsInDir.addItem('-> choose Material')
for i in self.pathList:
self.formUi.comboBox_MaterialsInDir.addItem(os.path.basename(i) )

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>194</width>
<width>196</width>
<height>142</height>
</rect>
</property>
@ -63,25 +63,31 @@
</property>
<property name="minimumSize">
<size>
<width>60</width>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="decimals">
<number>3</number>
</property>
<property name="maximum">
<double>999999.989999999990687</double>
<double>2000.000000000000000</double>
</property>
<property name="singleStep">
<double>2.000000000000000</double>
</property>
<property name="value">
<double>70000.000000000000000</double>
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Young Modulus (kPa)</string>
<string>Young's Mod.(GPa)</string>
</property>
</widget>
</item>
@ -95,13 +101,19 @@
</property>
<property name="minimumSize">
<size>
<width>60</width>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="decimals">
<number>3</number>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>

View File

@ -24,3 +24,6 @@ SpecificPrice= 3
YoungsModulus=2.32e+06
; http://en.wikipedia.org/wiki/Ultimate_tensile_strength in kPa
UltimateTensileStrength= 38000
[FEM]
PoissonRatio = 0.35

View File

@ -24,3 +24,7 @@ SpecificPrice= 4
YoungsModulus=3.64e+06
; http://en.wikipedia.org/wiki/Ultimate_tensile_strength in kPa
UltimateTensileStrength= 49600
[FEM]
PoissonRatio = 0.36

View File

@ -30,3 +30,6 @@ CompressiveStrength=
Elasticity=
; http://en.wikipedia.org/wiki/Fracture_toughness
FractureToughness:
[FEM]
PoissonRatio = 0.3