[FEM] Elecrostatic: use App::PropertyElectricPotential
This commit is contained in:
@@ -30,6 +30,7 @@ __url__ = "https://www.freecadweb.org"
|
||||
# \ingroup FEM
|
||||
# \brief constraint electrostatic potential object
|
||||
|
||||
from FreeCAD import Units
|
||||
from . import base_fempythonobject
|
||||
|
||||
|
||||
@@ -47,10 +48,10 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject)
|
||||
def add_properties(self, obj):
|
||||
if not hasattr(obj, "Potential"):
|
||||
obj.addProperty(
|
||||
"App::PropertyFloat",
|
||||
"App::PropertyElectricPotential",
|
||||
"Potential",
|
||||
"Parameter",
|
||||
"Potential"
|
||||
"Electric Potential"
|
||||
),
|
||||
obj.Potential = 0.0
|
||||
|
||||
|
||||
@@ -462,10 +462,9 @@ class Writer(object):
|
||||
for obj in self._getMember("Fem::ConstraintElectrostaticPotential"):
|
||||
if obj.References:
|
||||
for name in obj.References[0][1]:
|
||||
# https://forum.freecadweb.org/viewtopic.php?f=18&t=41488&start=10#p369454 ff
|
||||
if obj.PotentialEnabled:
|
||||
if hasattr(obj, "Potential"):
|
||||
potential = self._getFromUi(obj.Potential, "V", "M*L^2/(T^3 * I)")
|
||||
potential = float(obj.Potential.getValueAs("V"))
|
||||
self._boundary(name, "Potential", potential)
|
||||
if obj.PotentialConstant:
|
||||
self._boundary(name, "Potential Constant", True)
|
||||
|
||||
@@ -91,10 +91,8 @@ class _TaskPanel(object):
|
||||
self._part.ViewObject.hide()
|
||||
|
||||
def _initParamWidget(self):
|
||||
unit = "V"
|
||||
quantity = Units.Quantity("{} {}".format(self._obj.Potential, unit))
|
||||
self._paramWidget.potentialQSB.setProperty(
|
||||
'value', quantity)
|
||||
'value', self._obj.Potential)
|
||||
self._paramWidget.potentialBox.setChecked(
|
||||
not self._obj.PotentialEnabled)
|
||||
self._paramWidget.potentialConstantBox.setChecked(
|
||||
@@ -125,13 +123,12 @@ class _TaskPanel(object):
|
||||
potential = Units.Quantity(self._paramWidget.potentialQSB.text())
|
||||
except ValueError:
|
||||
FreeCAD.Console.PrintMessage(
|
||||
"Wrong input. OK has been triggered without a green hook "
|
||||
"in the input field. Not recognised input: '{}' "
|
||||
"Wrong input. Not recognised input: '{}' "
|
||||
"Potential has not been set.\n"
|
||||
.format(self._paramWidget.potentialTxt.text())
|
||||
.format(self._paramWidget.potentialQSB.text())
|
||||
)
|
||||
if potential is not None:
|
||||
self._obj.Potential = potential.getValueAs(unit).Value
|
||||
self._obj.Potential = potential
|
||||
|
||||
self._obj.PotentialConstant = self._paramWidget.potentialConstantBox.isChecked()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user