How to use C3D10 instead of C3D4 elements?
Moderator: bernd
Forum rules
and Helpful information for the FEM forum
and Helpful information for the FEM forum
Re: How to use C3D10 instead of C3D4 elements?
This sounds more like an issue with PySide http://tech-artists.org/forum/showthrea ... ev-in-maya
"MeshGmsh" is not the FEM mesh but it's the class name of the widget, it is derived from QtGui.QWidget. And "event" is a method of QWidget and that it apparently doesn't exist could be an indication for problems when deleting the widget.
And there is definitely a bug in the script because it also creates a QDockWidget to embed the MeshGmsh. When pressing Cancel it deletes the MeshGmsh widget but not its parent widget the QDockWidget which is only hidden.
"MeshGmsh" is not the FEM mesh but it's the class name of the widget, it is derived from QtGui.QWidget. And "event" is a method of QWidget and that it apparently doesn't exist could be an indication for problems when deleting the widget.
And there is definitely a bug in the script because it also creates a QDockWidget to embed the MeshGmsh. When pressing Cancel it deletes the MeshGmsh widget but not its parent widget the QDockWidget which is only hidden.
Re: How to use C3D10 instead of C3D4 elements?
I added this to the macro:
and that's the output (I use tablet):
The events are generated when cursor is entering/leaving macro window.
I'll change "print" to "pass" - it might settle the problem.
It could be that once in a while there was an event that wasn't handled by anything and the macro got blamed for it. I don't know if adding an empty event handler can fix it, but I'll know soon.
Edit:
New error, so I'll test "return False"
Edit1:
Didn't help, but I found a way of reproducing the error (6 out of 6 tests crashed).
1. New document
2. Part wb
3. Start the macro
4. Create cube
5. Switch to Draft --> Crash with message "Workbench failure" "'MeshGmsh' object has no attribute 'event'"
Code: Select all
def event(self, event):
print "Event called with param: {} of type {}".format(event, type(event))
Code: Select all
Event called with param: <0x7fff32422a80 at 0x7f0d641253b0> of type <type 'PySide.QtGui.QTabletEvent'>
Event called with param: <0x7fff32422a80 at 0x7f0d641253b0> of type <type 'PySide.QtGui.QTabletEvent'>
Event called with param: <0x7fff32422e50 at 0x7f0d641253b0> of type <type 'PySide.QtGui.QTabletEvent'>
Event called with param: <0x7fff32422e50 at 0x7f0d641253b0> of type <type 'PySide.QtGui.QTabletEvent'>
Event called with param: <0x7fff32422e50 at 0x7f0d641253b0> of type <type 'PySide.QtGui.QTabletEvent'>
Event called with param: <0x7fff32422e50 at 0x7f0d641253b0> of type <type 'PySide.QtGui.QTabletEvent'>
Event called with param: <0x7fff32422e50 at 0x7f0d641253b0> of type <type 'PySide.QtGui.QTabletEvent'>
Event called with param: <0x7fff32422e50 at 0x7f0d641253b0> of type <type 'PySide.QtGui.QTabletEvent'>
Event called with param: <0x7fff32422d10 at 0x7f0d641253b0> of type <type 'PySide.QtCore.QEvent'>
Event called with param: <0x7fff32423020 at 0x7f0d641253b0> of type <type 'PySide.QtCore.QEvent'>
Event called with param: <0x7fff32422420 at 0x7f0d641253b0> of type <type 'PySide.QtGui.QPaintEvent'>
Event called with param: <0x7fff32422420 at 0x7f0d641253b0> of type <type 'PySide.QtGui.QPaintEvent'>
I'll change "print" to "pass" - it might settle the problem.
It could be that once in a while there was an event that wasn't handled by anything and the macro got blamed for it. I don't know if adding an empty event handler can fix it, but I'll know soon.
Edit:
New error, so I'll test "return False"
Code: Select all
/home/przemo/.FreeCAD/GMSHMesh.FCMacro:19: RuntimeWarning: Invalid return value in function QWidget.event, expected bool, got NoneType.
self.initUI()
sys:1: RuntimeWarning: Invalid return value in function QWidget.event, expected bool, got NoneType.
bin/FreeCAD:145: RuntimeWarning: Invalid return value in function QWidget.event, expected bool, got NoneType.
Didn't help, but I found a way of reproducing the error (6 out of 6 tests crashed).
1. New document
2. Part wb
3. Start the macro
4. Create cube
5. Switch to Draft --> Crash with message "Workbench failure" "'MeshGmsh' object has no attribute 'event'"
Re: How to use C3D10 instead of C3D4 elements?
OK, I can confirm this behaviour on Windows, too. However, the steps to create a document or a cube are irrelevant. Just start the macro when FreeCAD starts. Then you can switch to the various workbenches and the widget gets partially destroyed when switching to these workbenches:
- Arch
- Draft
Re: How to use C3D10 instead of C3D4 elements?
It turns out to be a pivy/PySide problem. Make sure to not have loaded any workbench that uses pivy. If you then start the macro and type this into the Python console the widget gets partially destroyed.
So, it's definitely not a FreeCAD bug.
Code: Select all
from pivy import coin
Re: How to use C3D10 instead of C3D4 elements?
Loading pivy after the macro is executed seems to seriously damage the Python interpreter. Whatever Python code is executed afterwards there is always raised an exception. As a workaround you can put this as very first line inside the macro:
Code: Select all
from pivy import coin
Re: How to use C3D10 instead of C3D4 elements?
Thanks! Looks like it's working as expected
Updated macro here: https://github.com/PrzemoF/Macros_FreeC ... its/master
Updated macro here: https://github.com/PrzemoF/Macros_FreeC ... its/master
Re: How to use C3D10 instead of C3D4 elements?
I have found a better fix. I have no clue why all this happens and it's almost impossible to debug. So adding the __del__ method to MeshGmsh fixes this, too.
So, I assume that when importing pivy the __del__ method of the parent class was called and this destroys/invalidates the widget.
Code: Select all
def __del__(self):
return
Re: How to use C3D10 instead of C3D4 elements?
Then to fix the other problem where the QDockWidget is not destroyed you have to add:
Code: Select all
d = QtGui.QDockWidget()
d.toggleViewAction().setText("Gmsh")
d.setAttribute(QtCore.Qt.WA_DeleteOnClose)
Re: How to use C3D10 instead of C3D4 elements?
Thanks, applied!wmayer wrote:I have found a better fix. I have no clue why all this happens and it's almost impossible to debug. So adding the __del__ method to MeshGmsh fixes this, too.So, I assume that when importing pivy the __del__ method of the parent class was called and this destroys/invalidates the widget.Code: Select all
def __del__(self): return
Re: How to use C3D10 instead of C3D4 elements?
Thanks again! It's really important for me, as the FreeCAD build-in meshing doesn't work on my both installations (fedora) and I use gmsh as the main meshing tool.wmayer wrote:Then to fix the other problem where the QDockWidget is not destroyed you have to add:Code: Select all
d = QtGui.QDockWidget() d.toggleViewAction().setText("Gmsh") d.setAttribute(QtCore.Qt.WA_DeleteOnClose)