CalculixccxTools Task Panel Stays Active After Error

About the development of the FEM module/workbench.

Moderator: bernd

Post Reply
UR_
Posts: 1171
Joined: Tue Jan 03, 2017 8:42 pm

CalculixccxTools Task Panel Stays Active After Error

Post by UR_ » Sun Sep 22, 2019 11:45 am

Workflow to reproduce misbehavior:

- load cantilever3D example from FreeCAD's start page
- change Preferences->FEM->Calculix->ccx binary path to something not available (e.g. a typo in filename)
- open CalculixccxTools Task Panel
- error message appears

Screenshot 001.png
Screenshot 001.png (10.44 KiB) Viewed 574 times
[WinError 2] The system cannot find the file specifiedTraceback (most recent call last):
File "C:\Program Files\FreeCAD\Mod\Fem\femguiobjects\_ViewProviderFemSolverCalculix.py", line 68, in setEdit
taskd = _TaskPanelFemSolverCalculix(self.Object)
File "C:\Program Files\FreeCAD\Mod\Fem\femguiobjects\_ViewProviderFemSolverCalculix.py", line 106, in __init__
self.fea.setup_ccx()
File "C:\Program Files\FreeCAD\Mod\Fem\femtools\ccxtools.py", line 834, in setup_ccx
raise Exception(error_message)
<class 'Exception'>: FEM: CalculiX binary ccx 'C:/Program Files/FEMbinpack/bin/ccx_2.15_pardiso_dynamic.dhondt2.exe' not found. Please set the CalculiX binary ccx path in FEM preferences tab CalculiX.

Active Task Dialog found! Please close this one before opening a new one!

- afterwards open task no more closable :shock:


Done this minor changes to avoid this:

Code: Select all

diff U C:/Users/aio/FreeCADcode/src/Mod/Fem/femguiobjects/_ViewProviderFemSolverCalculix.py C:/Users/aio/Miniconda3/envs/freecad-dev/Library/Mod/Fem/femguiobjects/_ViewProviderFemSolverCalculix.py
--- C:/Users/aio/FreeCADcode/src/Mod/Fem/femguiobjects/_ViewProviderFemSolverCalculix.py	Sun Sep 15 07:33:55 2019
+++ C:/Users/aio/Miniconda3/envs/freecad-dev/Library/Mod/Fem/femguiobjects/_ViewProviderFemSolverCalculix.py	Sun Sep 22 13:04:25 2019
@@ -106,2 +106,5 @@
-        self.fea.setup_ccx()
-
+        try:
+            self.fea.setup_ccx()
+        except:
+            FreeCAD.Console.PrintError("setup ccx failed \n")
+            

Code: Select all

diff U C:/Users/aio/Miniconda3/envs/freecad-dev/Library/Mod/Fem/femtools/ccxtools.py C:/Users/aio/FreeCADCode/src/Mod/Fem/femtools/ccxtools.py
--- C:/Users/aio/Miniconda3/envs/freecad-dev/Library/Mod/Fem/femtools/ccxtools.py	Sun Sep 22 12:59:00 2019
+++ C:/Users/aio/FreeCADCode/src/Mod/Fem/femtools/ccxtools.py	Fri Sep 20 14:25:52 2019
@@ -855 +855 @@
-            FreeCAD.Console.PrintError(str(e) + "\n")
+            FreeCAD.Console.PrintError(str(e))
@@ -867 +867 @@
-            FreeCAD.Console.PrintError(str(e) + "\n")
+            FreeCAD.Console.PrintError(str(e))
_ViewProviderFemSolverCalculix.py.diff.zip
(479 Bytes) Downloaded 14 times
ccxtools.py.diff.zip
(384 Bytes) Downloaded 15 times
openBrain
Posts: 3350
Joined: Fri Nov 09, 2018 5:38 pm

Re: CalculixccxTools Task Panel Stays Active After Error

Post by openBrain » Sun Sep 22, 2019 1:10 pm

Something strange is that your diffs are done in opposite order. ;)

Also I don't advise to add a "\n" at the end of the error string as this will prevent the error message to be displayed in the status bar (as it will be immediately cleared by the carriage return). Better add it in the beginning of the string. ;)

Finally, I didn't try your patches, but maybe it would be good to also reject Edit in case of error to prevent another exception if user still uses the UI buttons. ;)
UR_
Posts: 1171
Joined: Tue Jan 03, 2017 8:42 pm

Re: CalculixccxTools Task Panel Stays Active After Error

Post by UR_ » Sun Sep 22, 2019 1:46 pm

openBrain wrote:
Sun Sep 22, 2019 1:10 pm
Something strange is that your diffs are done in opposite order.

Excuse me, my bad :man_facepalming:

Also I don't advise to add a "\n" at the end of the error string as this will prevent the error message to be displayed in the status bar (as it will be immediately cleared by the carriage return). Better add it in the beginning of the string. ;)

OMG, there are 141 occurrences, regarding only FEM WB :scream:

Code: Select all

C:\Users\aio\FreeCADcode\src\Mod\Fem\femcommands\manager.py
    217: FreeCAD.Console.PrintError(
C:\Users\aio\FreeCADcode\src\Mod\Fem\femexamples\ccx_cantilever_std.py
    101: FreeCAD.Console.PrintError("Error on creating nodes.\n")
    104: FreeCAD.Console.PrintError("Error on creating elements.\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femexamples\rc_wall_2d.py
    146: FreeCAD.Console.PrintError("Error on creating nodes.\n")
    149: FreeCAD.Console.PrintError("Error on creating elements.\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\_ViewProviderFemConstraintSelfWeight.py
     71: FreeCAD.Console.PrintError(message + "\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\_ViewProviderFemElementFluid1D.py
     99: FreeCAD.Console.PrintError(message + "\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\_ViewProviderFemElementGeometry1D.py
     96: FreeCAD.Console.PrintError(message + "\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\_ViewProviderFemElementGeometry2D.py
     95: FreeCAD.Console.PrintError(message + "\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\_ViewProviderFemElementRotation1D.py
    102: FreeCAD.Console.PrintError(message + "\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\_ViewProviderFemMaterial.py
     94: FreeCAD.Console.PrintError(message + "\n")
    269: FreeCAD.Console.PrintError(error_message)
    411: FreeCAD.Console.PrintError(error_message)
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\_ViewProviderFemMaterialMechanicalNonlinear.py
     81: FreeCAD.Console.PrintError(message + "\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\_ViewProviderFemMaterialReinforced.py
    103: FreeCAD.Console.PrintError(message + "\n")
    253: FreeCAD.Console.PrintError(error_message)
    417: FreeCAD.Console.PrintError(error_message)
    470: FreeCAD.Console.PrintError(error_message)
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\_ViewProviderFemMeshBoundaryLayer.py
     95: FreeCAD.Console.PrintError(message + "\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\_ViewProviderFemMeshGmsh.py
    104: FreeCAD.Console.PrintError(
    131: FreeCAD.Console.PrintError("Active analysis is not in active document.")
    164: FreeCAD.Console.PrintError(message + "\n")
    184: FreeCAD.Console.PrintError("Error in onDelete: " + err.message)
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\_ViewProviderFemMeshGroup.py
     94: FreeCAD.Console.PrintError(message + "\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\_ViewProviderFemMeshRegion.py
     95: FreeCAD.Console.PrintError(message + "\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\_ViewProviderFemResultMechanical.py
     76: FreeCAD.Console.PrintError(message + "\n")
     90: FreeCAD.Console.PrintError(error_message)
    115: FreeCAD.Console.PrintError("Error in onDelete: " + err.message)
    621: FreeCAD.Console.PrintError(error_message)
    625: FreeCAD.Console.PrintError(error_message)
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\_ViewProviderFemSolverCalculix.py
     84: FreeCAD.Console.PrintError(message + "\n")
    239: FreeCAD.Console.PrintError(match.strip().replace("\n", " ") + "\n")
    254: FreeCAD.Console.PrintError(error_message)
    327: FreeCAD.Console.PrintError("loading results failed\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\FemSelectionWidgets.py
    537: FreeCAD.Console.PrintError(
C:\Users\aio\FreeCADcode\src\Mod\Fem\femguiobjects\ViewProviderFemConstraint.py
     78: FreeCAD.Console.PrintError(message + "\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\feminout\importCcxFrdResults.py
    189: FreeCAD.Console.PrintError(
    722: FreeCAD.Console.PrintError(
    726: FreeCAD.Console.PrintError("FEM: No nodes found in Frd file.\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\feminout\importFenicsMesh.py
    125: FreeCAD.Console.PrintError(
    168: FreeCAD.Console.PrintError(
    173: FreeCAD.Console.PrintError("No FEM mesh object selected.\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\feminout\importInpMesh.py
    214: FreeCAD.Console.PrintError("Error: seg3 (3-node beam element type) not supported, yet.\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\feminout\importToolsFem.py
    239: FreeCAD.Console.PrintError("No Elements found!\n")
    241: FreeCAD.Console.PrintError("No Nodes found!\n")
    415: FreeCAD.Console.PrintError("PEEQ seams to have exptra nodes.\n")
    442: FreeCAD.Console.PrintError("Temperature seams to have exptra nodes.\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\feminout\importVTKResults.py
     74: FreeCAD.Console.PrintError(
     81: FreeCAD.Console.PrintError(
     86: FreeCAD.Console.PrintError(
     93: FreeCAD.Console.PrintError(
    122: FreeCAD.Console.PrintError(
C:\Users\aio\FreeCADcode\src\Mod\Fem\feminout\importYamlJsonMesh.py
     91: FreeCAD.Console.PrintError(
     97: FreeCAD.Console.PrintError("No FEM mesh object selected.\n")
    165: FreeCAD.Console.PrintError(
C:\Users\aio\FreeCADcode\src\Mod\Fem\feminout\importZ88Mesh.py
     81: FreeCAD.Console.PrintError("This exporter can only export one object.\n")
     85: FreeCAD.Console.PrintError("No FEM mesh object selected.\n")
    182: FreeCAD.Console.PrintError(
    229: FreeCAD.Console.PrintError(
    232: FreeCAD.Console.PrintError(
    238: FreeCAD.Console.PrintError(
    241: FreeCAD.Console.PrintError(
    247: FreeCAD.Console.PrintError(
    250: FreeCAD.Console.PrintError(
    256: FreeCAD.Console.PrintError(
    259: FreeCAD.Console.PrintError(
    265: FreeCAD.Console.PrintError(
    268: FreeCAD.Console.PrintError(
    274: FreeCAD.Console.PrintError(
    277: FreeCAD.Console.PrintError(
    395: FreeCAD.Console.PrintError("Unknown element\n")
    432: FreeCAD.Console.PrintError("Not a FemMesh was given as parameter.\n")
    464: FreeCAD.Console.PrintError("Error: wrong z88_element_type.\n")
    548: FreeCAD.Console.PrintError(
C:\Users\aio\FreeCADcode\src\Mod\Fem\feminout\importZ88O2Results.py
    102: FreeCAD.Console.PrintError("Z88 mesh file z88i1.txt not found!")
    121: FreeCAD.Console.PrintError(
C:\Users\aio\FreeCADcode\src\Mod\Fem\femmesh\gmshtools.py
    191: FreeCAD.Console.PrintError("You can not mesh a Vertex.\n")
    202: FreeCAD.Console.PrintError(
    230: FreeCAD.Console.PrintError(
    245: FreeCAD.Console.PrintError(
    291: FreeCAD.Console.PrintError(error_message)
    299: FreeCAD.Console.PrintError(error_message)
    331: FreeCAD.Console.PrintError("  A group with this name exists already.\n")
    348: FreeCAD.Console.PrintError("  A group with this name exists already.\n")
    380: FreeCAD.Console.PrintError(error_message + "\n")
    419: FreeCAD.Console.PrintError(
    430: FreeCAD.Console.PrintError(
    436: FreeCAD.Console.PrintError(
    442: FreeCAD.Console.PrintError(
    474: FreeCAD.Console.PrintError(err + "\n")
    508: FreeCAD.Console.PrintError(
    521: FreeCAD.Console.PrintError(
    553: FreeCAD.Console.PrintError(
    558: FreeCAD.Console.PrintError(
    564: FreeCAD.Console.PrintError(
    814: FreeCAD.Console.PrintError(error)
    824: FreeCAD.Console.PrintError("No mesh was created.\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femmesh\meshtools.py
    154: FreeCAD.Console.PrintError("Neither solid nor face nor edge femmesh!\n")
    459: FreeCAD.Console.PrintError(
    516: FreeCAD.Console.PrintError(
    576: FreeCAD.Console.PrintError("Multiple Rotations not yet supported!\n")
    713: FreeCAD.Console.PrintError(
    738: FreeCAD.Console.PrintError(
    842: FreeCAD.Console.PrintError(
   1008: FreeCAD.Console.PrintError(
   1114: FreeCAD.Console.PrintError(
   1248: FreeCAD.Console.PrintError("Error: Empty femnodes_mesh or face_table!\n")
   1423: FreeCAD.Console.PrintError(
   1441: FreeCAD.Console.PrintError(
   1462: FreeCAD.Console.PrintError(
   1484: FreeCAD.Console.PrintError(
   1504: FreeCAD.Console.PrintError(
   1524: FreeCAD.Console.PrintError(
   1530: FreeCAD.Console.PrintError(
   1590: FreeCAD.Console.PrintError(
   1601: FreeCAD.Console.PrintError(
   1645: FreeCAD.Console.PrintError(
   1681: FreeCAD.Console.PrintError(
   1702: FreeCAD.Console.PrintError(
   1751: FreeCAD.Console.PrintError(
   1759: FreeCAD.Console.PrintError(
   1768: FreeCAD.Console.PrintError(
   1787: FreeCAD.Console.PrintError("This should not happen, please debug!\n")
   1819: FreeCAD.Console.PrintError(
   1831: FreeCAD.Console.PrintError(
   1884: FreeCAD.Console.PrintError(
   1921: FreeCAD.Console.PrintError("Compound is not supported.\n")
   1942: FreeCAD.Console.PrintError(
   1970: FreeCAD.Console.PrintError("Compound is not supported.\n")
   2020: FreeCAD.Console.PrintError(
C:\Users\aio\FreeCADcode\src\Mod\Fem\femresult\resulttools.py
    138: FreeCAD.Console.PrintError("Error, No result object given.\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femsolver\calculix\writer.py
    124: FreeCAD.Console.PrintError(
   1217: FreeCAD.Console.PrintError(
C:\Users\aio\FreeCADcode\src\Mod\Fem\femsolver\fenics\fenics_tools.py
     35: FreeCAD.Console.PrintError("No Fenics modules found, please install them.\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femsolver\settings.py
    133: FreeCAD.Console.PrintError(
    145: FreeCAD.Console.PrintError(
C:\Users\aio\FreeCADcode\src\Mod\Fem\femsolver\writerbase.py
     85: FreeCAD.Console.PrintError(
    110: FreeCAD.Console.PrintError(
C:\Users\aio\FreeCADcode\src\Mod\Fem\femsolver\z88\writer.py
    219: FreeCAD.Console.PrintError("Multiple Materials for Z88 not yet supported!\n")
    237: FreeCAD.Console.PrintError("Multiple beamsections for Z88 not yet supported!\n")
    246: FreeCAD.Console.PrintError(
    252: FreeCAD.Console.PrintError("Error!\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femtools\ccxtools.py
    471: FreeCAD.Console.PrintError(
    681: FreeCAD.Console.PrintError(
    695: FreeCAD.Console.PrintError(
    701: FreeCAD.Console.PrintError(
    715: FreeCAD.Console.PrintError(
    757: FreeCAD.Console.PrintError(
    855: FreeCAD.Console.PrintError(str(e))
    867: FreeCAD.Console.PrintError(str(e))
    943: FreeCAD.Console.PrintError("CalculiX can not be run if test_mode is True.\n")
    971: FreeCAD.Console.PrintError("CalculiX failed with exit code {}\n".format(ret_code))
    995: FreeCAD.Console.PrintError(error_message)
   1007: FreeCAD.Console.PrintError(error_message)
   1025: FreeCAD.Console.PrintError(error_message)
   1064: FreeCAD.Console.PrintError(
   1120: FreeCAD.Console.PrintError(
   1175: FreeCAD.Console.PrintError("FEM: No result object in active Analysis.\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\femtools\femutils.py
    192: FreeCAD.Console.PrintError(error_message + "\n")
    209: FreeCAD.Console.PrintError(error_message + "\n")
C:\Users\aio\FreeCADcode\src\Mod\Fem\Gui\Command.cpp
   1179: FreeCAD.Console.PrintError('membrane stress = ')\n\
   1180: FreeCAD.Console.PrintError([str(round(membrane[0],2))])\n\
   1181: FreeCAD.Console.PrintError('membrane + bending min = ')\n\
   1182: FreeCAD.Console.PrintError([str(round(mb[0],2))])\n\
   1183: FreeCAD.Console.PrintError('membrane + bending  max = ')\n\
   1184: FreeCAD.Console.PrintError([str(round(mb[len(t_coords)-1],2))])\n\
   1185: FreeCAD.Console.PrintError('Total stress min = ')\n\
   1186: FreeCAD.Console.PrintError([str(round(peak[0],2))])\n\
   1187: FreeCAD.Console.PrintError('Total stress max = ')\n\
   1188: FreeCAD.Console.PrintError([str(round(peak[len(t_coords)-1],2))])\n\
C:\Users\aio\FreeCADcode\src\Mod\Fem\ObjectsFem.py
    292: FreeCAD.Console.PrintError("Section type is not known. Set to " + sec_types[0] + " \n")

@bernd - "The Code Formatter"
looks like your turn :lol:
UR_
Posts: 1171
Joined: Tue Jan 03, 2017 8:42 pm

Re: CalculixccxTools Task Panel Stays Active After Error

Post by UR_ » Sun Sep 22, 2019 5:13 pm

Just another observation beside:

if above mentioned QMessageBox is fired up, often another window (in my case an accidentally in background shown editor) is brought to foreground instead of desired QMessageBox :(

changing code from:

Code: Select all

QtGui.QMessageBox.critical( None, error_title, error_message)

to:

Code: Select all

import FreeCADGui
QtGui.QMessageBox.critical( FreeCADGui.getMainWindow(), error_title, error_message)

prevents from this.

Is there a reason why parent is set to None :thinking:
vocx
Posts: 3245
Joined: Thu Oct 18, 2018 9:18 pm

Re: CalculixccxTools Task Panel Stays Active After Error

Post by vocx » Sun Sep 22, 2019 5:42 pm

openBrain wrote:
Sun Sep 22, 2019 1:10 pm
...
Also I don't advise to add a "\n" at the end of the error string as this will prevent the error message to be displayed in the status bar (as it will be immediately cleared by the carriage return). Better add it in the beginning of the string. ;)
...
This is ridiculous. A carriage return should come at the end of a line, not at the beginning. If the status bar doesn't handle that appropriately, then that's a problem of the status bar.

Also, who cares about the status bar? The Console messages are supposed to be displayed in the Report view, the terminal, or the log file, so this is a non-issue.
Always add the important information to your posts if you need help.
To support the documentation effort, and code development, your donation is appreciated: paypal.
openBrain
Posts: 3350
Joined: Fri Nov 09, 2018 5:38 pm

Re: CalculixccxTools Task Panel Stays Active After Error

Post by openBrain » Sun Sep 22, 2019 5:56 pm

vocx wrote:
Sun Sep 22, 2019 5:42 pm
This is ridiculous. A carriage return should come at the end of a line, not at the beginning. If the status bar doesn't handle that appropriately, then that's a problem of the status bar.
You're right. Moreover this seems to work properly now. I had some problem with that in the past, but it no more exists. Nevermind.
Also, who cares about the status bar? The Console messages are supposed to be displayed in the Report view, the terminal, or the log file, so this is a non-issue.
This is more ridiculous a sentence than everything you may have called ridiculous. :roll: Please stopping thinking you're owning the whole truth ever. :roll:
UR_
Posts: 1171
Joined: Tue Jan 03, 2017 8:42 pm

Re: CalculixccxTools Task Panel Stays Active After Error

Post by UR_ » Wed Sep 25, 2019 6:57 am

UR_
Posts: 1171
Joined: Tue Jan 03, 2017 8:42 pm

Re: CalculixccxTools Task Panel Stays Active After Error

Post by UR_ » Fri Sep 27, 2019 11:24 am

bernd wrote: :bell:

I'm feeling sooo ignored :sob:
User avatar
bernd
Posts: 9245
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: CalculixccxTools Task Panel Stays Active After Error

Post by bernd » Fri Sep 27, 2019 4:01 pm

keep calm, I am just overwhlemed with work at work and on FreeCAD and ahh very important there is anotherone ... There is a little princess and she has her 4th birthday this weekend ... yeah and there will be join us another 9 little princesses and the parants too. :shock: :o

It will be fixed ...

BTW: this should not be done in the task panel but in the method which searches for the solver ... I need to have a look ...
Post Reply

Who is online

Users browsing this forum: qingfeng.xia and 1 guest