diff --git a/src/Mod/Fem/App/FemMeshPyImp.cpp b/src/Mod/Fem/App/FemMeshPyImp.cpp index a54010052..ab67ddf2a 100755 --- a/src/Mod/Fem/App/FemMeshPyImp.cpp +++ b/src/Mod/Fem/App/FemMeshPyImp.cpp @@ -63,9 +63,38 @@ PyObject *FemMeshPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Py // constructor method int FemMeshPy::PyInit(PyObject* args, PyObject* /*kwd*/) { + PyObject *pcObj=0; + if (!PyArg_ParseTuple(args, "|O", &pcObj)) // convert args: Python->C + return -1; // NULL triggers exception + + try { + // if no mesh is given + if (!pcObj) return 0; + if (PyObject_TypeCheck(pcObj, &(FemMeshPy::Type))) { + getFemMeshPtr()->operator= (*static_cast(pcObj)->getFemMeshPtr()); + } + else { + PyErr_Format(PyExc_TypeError, "Cannot create a FemMesh out of a '%s'", + pcObj->ob_type->tp_name); + return -1; + } + } + catch (const Base::Exception &e) { + PyErr_SetString(PyExc_Exception,e.what()); + return -1; + } + catch (const std::exception &e) { + PyErr_SetString(PyExc_Exception,e.what()); + return -1; + } + catch (const Py::Exception&) { + return -1; + } + return 0; } + // ===== Methods ============================================================ PyObject* FemMeshPy::setShape(PyObject *args) diff --git a/src/Mod/Machining_Distortion/InitGui.py b/src/Mod/Machining_Distortion/InitGui.py index 5b323bddc..a603d112f 100755 --- a/src/Mod/Machining_Distortion/InitGui.py +++ b/src/Mod/Machining_Distortion/InitGui.py @@ -167,7 +167,7 @@ class MachiningDistortionWorkbench ( Workbench ): self.appendToolbar("MachiningDistortionTools2",CmdList2) self.appendMenu("Machining Distortion2",CmdList2) - self.setWatchers() + #self.setWatchers() Gui.addPreferencePage(":/ui/userprefs-base.ui","Machining Distortion") @@ -175,10 +175,11 @@ class MachiningDistortionWorkbench ( Workbench ): def Activated(self): self.setWatchers() FreeCADGui.Control.showTaskView() - Msg("MachiningDistortionWorkbench::Activated()\n") + Msg("PartDistortionWorkbench::Activated()\n") def Deactivated(self): - Msg("MachiningDistortionWorkbench::Deactivated()\n") + FreeCADGui.Control.clearTaskWatcher() + Msg("PartDistortionWorkbench::Deactivated()\n") Gui.addWorkbench(MachiningDistortionWorkbench) diff --git a/src/Mod/Machining_Distortion/MachDistAlignment.py b/src/Mod/Machining_Distortion/MachDistAlignment.py index 56fa72d2a..6c646a3cd 100644 --- a/src/Mod/Machining_Distortion/MachDistAlignment.py +++ b/src/Mod/Machining_Distortion/MachDistAlignment.py @@ -58,11 +58,16 @@ class _CommandAlignment: # switch on Bound Box FemMeshObject.ViewObject.BoundingBox = True - + QtGui.qApp.setOverrideCursor(QtCore.Qt.WaitCursor) n = FemMeshObject.FemMesh.Nodes p = Mesh.calculateEigenTransform(n) - p2 = p.inverse() - FemMeshObject.Placement = p2 + #FemMeshObject.Placement = p + m = Fem.FemMesh(FemMeshObject.FemMesh) + m.setTransform(p) + FemMeshObject.FemMesh = m + FemMeshObject.Placement = FreeCAD.Placement() + + QtGui.qApp.restoreOverrideCursor() taskd = _AlignTaskPanel(FemMeshObject) FreeCADGui.Control.showDialog(taskd)