[Solved] FEM doesn't work anymore

About the development of the FEM module/workbench.

Moderator: bernd

ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: FEM doesn't work anymore

Post by ElMastro »

Sorry, I misunderstood. Running the code alone it gives back no reply, however, If I run it after building the box and starting the analysis, this is the Python console:

Code: Select all

Python 3.7.3 (default, Mar 26 2019, 21:43:19) 
[GCC 8.2.1 20181127] on linux
Type 'help', 'copyright', 'credits' or 'license' for more information.
>>> FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/MeshGmsh.ui"
'/usr/lib/freecad/Mod/Fem/Resources/ui/MeshGmsh.ui'
>>> form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/MeshGmsh.ui")
>>> form
<PySide2.QtWidgets.QWidget object at 0x7fa888755288>
>>> form.if_max # this doesn't seem to work for you
Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: 'PySide2.QtWidgets.QWidget' object has no attribute 'if_max'
>>> 
>>> from PySide2 import QtWidgets
>>> 
>>> f=form.findChildren(QtWidgets.QLineEdit)
>>> f[0].metaObject().className()
'Gui::InputField'
>>> f[0].objectName()
'if_max'
>>> 
>>> form.show()
>>> App.newDocument("Senza nome")
>>> App.setActiveDocument("Senza_nome")
>>> App.ActiveDocument=App.getDocument("Senza_nome")
>>> Gui.ActiveDocument=Gui.getDocument("Senza_nome")
>>> Gui.activeDocument().activeView().viewDefaultOrientation()
>>> Gui.activateWorkbench("PartWorkbench")
>>> App.ActiveDocument.addObject("Part::Cylinder","Cylinder")
>>> App.ActiveDocument.ActiveObject.Label = "Cilindro"
>>> App.ActiveDocument.recompute()
>>> Gui.SendMsgToActiveView("ViewFit")
>>> App.getDocument("Senza_nome").removeObject("Cylinder")
>>> App.getDocument("Senza_nome").recompute()
>>> App.ActiveDocument.addObject("Part::Box","Box")
>>> App.ActiveDocument.ActiveObject.Label = "Cubo"
>>> App.ActiveDocument.recompute()
>>> Gui.SendMsgToActiveView("ViewFit")
>>> Gui.activateWorkbench("FemWorkbench")
>>> import FemGui
>>> import ObjectsFem
>>> ObjectsFem.makeAnalysis(FreeCAD.ActiveDocument, 'Analysis')
>>> FemGui.setActiveAnalysis(FreeCAD.ActiveDocument.ActiveObject)
>>> ObjectsFem.makeSolverCalculixCcxTools(FreeCAD.ActiveDocument)
>>> FemGui.getActiveAnalysis().addObject(FreeCAD.ActiveDocument.ActiveObject)
>>> form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/MeshGmsh.ui")
>>> form
<PySide2.QtWidgets.QWidget object at 0x7fa83bec4fc8>
>>> form.if_max # this doesn't seem to work for you
Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: 'PySide2.QtWidgets.QWidget' object has no attribute 'if_max'
Tracebacks are in red.
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FEM doesn't work anymore

Post by wmayer »

I think there might be a bug in your PySide2 package. From the test code everything except form.if_max works.

Here is a slight modification you can try:

Code: Select all

from PySide2 import QtCore, QtGui, QtWidgets
import FreeCADGui
loader = FreeCADGui.UiLoader()
form = loader.load(FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/MeshGmsh.ui")
form.if_max
f=form.findChildren(QtWidgets.QLineEdit)
f[0].metaObject().className()
f[0].objectName()
form.show()
So, somewhere a mechanism is implemented which automatically adds the sub-controls as attributes to the form object. For those where it works you can see this with

Code: Select all

dir(form).index("if_max")
where a number is returned, otherwise an exception is raised.

Next test:
Open QtDesigner and create a standard dialog with two buttons, save the file as dialog.ui (e.g. under C:/Temp).
Now from a standard Python shell (not that of FreeCAD) do

Code: Select all

from PySide2 import QtCore, QtGui, QtWidgets
from PySide2 import QtUiTools
import sys

app=QtWidgets.QApplication(sys.argv)

ui=QtUiTools.QUiLoader()
dialog=ui.load("C:/Temp/dialog.ui")
dialog.buttonBox
If the last line also fails then your PySide2 is broken.
ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: FEM doesn't work anymore

Post by ElMastro »

from PySide2 import QtCore, QtGui, QtWidgets
import FreeCADGui
loader = FreeCADGui.UiLoader()
form = loader.load(FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/MeshGmsh.ui")
form.if_max
f=form.findChildren(QtWidgets.QLineEdit)
f[0].metaObject().className()
f[0].objectName()
form.show()
Same results;
As I enter
dir(form).index("if_max")
output is

Code: Select all

Traceback (most recent call last):
  File "<input>", line 1, in <module>
ValueError: 'if_max' is not in list
I can't find Qtdesigner, probably in linux has been renamed to something else, I'll try the code as soon as I can install it. At this point I'm pretty sure PySide2 could be broken, so in the time I'll reinstall it and ask to the mantainer if someone else has experienced problems
ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: FEM doesn't work anymore

Post by ElMastro »

All right, the command that launch Qtdesigner in linux is "desinger".
I saved the gui and run the code, output is

Code: Select all

Python 3.7.3 (default, Mar 26 2019, 21:43:19) 
[GCC 8.2.1 20181127] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PySide2 import QtCore, QtGui, QtWidgets
>>> from PySide2 import QtUiTools
>>> import sys
>>> 
>>> app=QtWidgets.QApplication(sys.argv)
>>> 
>>> ui=QtUiTools.QUiLoader()
QVTKWidgetPlugin instantiated

QVTKWidgetPlugin::name

Qt WebEngine seems to be initialized from a plugin. Please set Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute before constructing QGuiApplication.
>>> dialog=ui.load("/tmp/dialog.ui")
>>> dialog.buttonBox
<PySide2.QtWidgets.QDialogButtonBox object at 0x7fcdc6b0c808>
>>> 

(Nothing appears)
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: FEM doesn't work anymore

Post by Kunda1 »

ElMastro wrote: Sun Jun 02, 2019 8:56 am All right, the command that launch Qtdesigner in linux is "desinger".
You mean designer and more aptly designer-qt5
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: FEM doesn't work anymore

Post by ElMastro »

You mean designer and more aptly designer-qt5
Exactly, I misspelled.

I started a post on the archlinux forum to confirm if I'm the only one with this problem, but I got no answer yet
https://bbs.archlinux.org/viewtopic.php?id=246769
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FEM doesn't work anymore

Post by wmayer »

>>> dialog=ui.load("/tmp/dialog.ui")
>>> dialog.buttonBox
<PySide2.QtWidgets.QDialogButtonBox object at 0x7fcdc6b0c808>
It's strange that it works for built-in Qt widgets but fails for custom widgets.

What happens with this when doing it in the FreeCAD Python console?

Code: Select all

from PySide2 import QtCore, QtGui, QtWidgets

ui=FreeCADGui.UiLoader()
dialog=ui.load("/tmp/dialog.ui")
dialog.buttonBox
And you can try this:

Code: Select all

from PySide2 import QtCore, QtGui, QtWidgets
import FreeCADGui
loader = FreeCADGui.UiLoader()
form = loader.load(FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/MeshGmsh.ui")

print (dir(form)) # post this output please
I assume that it only reports built-in widgets but ignores custom widgets.
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FEM doesn't work anymore

Post by wmayer »

I started a post on the archlinux forum to confirm if I'm the only one with this problem, but I got no answer yet
https://bbs.archlinux.org/viewtopic.php?id=246769
With this you probably won't get much feedback because nobody knows what to test actually. You should at least post the link to this thread.

Btw which PySide version do you use?
ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: FEM doesn't work anymore

Post by ElMastro »

I use the 5.12.3-1 version.
I wrote an email to the mantainer to know if he knows anything about this problem.
ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: FEM doesn't work anymore

Post by ElMastro »

Something is definitively wrong. When I search for Pyside2 in the AUR repsitory what I find is

Code: Select all

aur/pyside2-common-git 5.11.2.r5903.ae51319f-1 (+2 0.00%) 
    LGPL Qt bindings for Python (Common Files)
aur/pyside2-tools-common-git 5.11.1.r117.f1b7755-1 (+0 0.00%) (Orphaned) 
    PySide lupdate, rcc, and uic development tools (Common Files)
aur/python-pyside2-git 5.11.2.r5903.ae51319f-1 (+2 0.00%) 
    LGPL Qt bindings for Python 3
aur/python-pyside2-tools-git 5.11.1.r117.f1b7755-1 (+0 0.00%) (Orphaned) 
    PySide lupdate, rcc, and uic development tools (for Python 3)
aur/python2-pyside2-git 5.11.2.r5903.ae51319f-1 (+2 0.00%) 
    LGPL Qt bindings for Python 2
aur/python2-pyside2-tools-git 5.11.1.r117.f1b7755-1 (+0 0.00%) (Orphaned) 
    PySide lupdate, rcc, and uic development tools (for Python 2)
However my version of pyside2 is 12.3 (current one on git repositories). It would be great if someone who does have Pyside2 up to date could tell me where to get it.
Post Reply