From: eap Date: Tue, 29 Mar 2005 09:59:34 +0000 (+0000) Subject: "Dump Python". fix for work without a study X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=108ee5d360eee86e61673f8947c333b0e14d5b5b;p=modules%2Fsmesh.git "Dump Python". fix for work without a study --- diff --git a/src/SMESH_I/SMESH_Gen_i_DumpPython.cxx b/src/SMESH_I/SMESH_Gen_i_DumpPython.cxx index 36ec9b1a0..16ae06a32 100644 --- a/src/SMESH_I/SMESH_Gen_i_DumpPython.cxx +++ b/src/SMESH_I/SMESH_Gen_i_DumpPython.cxx @@ -320,7 +320,8 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl anUpdatedScript += "\n"; // Set object names - anUpdatedScript += "\n\tisGUIMode = 1"; + anUpdatedScript += "\n\tisGUIMode = "; + anUpdatedScript += isPublished; anUpdatedScript += "\n\tif isGUIMode:"; anUpdatedScript += "\n\t\tsmeshgui = salome.ImportComponentGUI(\"SMESH\")"; anUpdatedScript += "\n\t\tsmeshgui.Init(theStudy._get_StudyId())"; diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 518cc11fe..51f792b80 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -528,16 +528,17 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Object_ptr aSubShap SALOMEDS::SObject_var aSO = _gen_i->PublishSubMesh(_gen_i->GetCurrentStudy(), aMesh, subMesh, aSubShapeObject, theName ); - - // Update Python script - TCollection_AsciiString aStr (aSO->GetID()); - aStr += " = "; - SMESH_Gen_i::AddObject(aStr, _this()) += ".GetSubMesh("; - SMESH_Gen_i::AddObject(aStr, aSubShapeObject) += ", \""; - aStr += (char*)theName; - aStr += "\")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + if ( !aSO->_is_nil()) { + // Update Python script + TCollection_AsciiString aStr (aSO->GetID()); + aStr += " = "; + SMESH_Gen_i::AddObject(aStr, _this()) += ".GetSubMesh("; + SMESH_Gen_i::AddObject(aStr, aSubShapeObject) += ", \""; + aStr += (char*)theName; + aStr += "\")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + } } } catch(SALOME_Exception & S_ex) { @@ -633,14 +634,15 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType SALOMEDS::SObject_var aSO = _gen_i->PublishGroup(_gen_i->GetCurrentStudy(), _this(), aNewGroup, GEOM::GEOM_Object::_nil(), theName); + if ( !aSO->_is_nil()) { + // Update Python script + TCollection_AsciiString aStr (aSO->GetID()); + aStr += " = "; + SMESH_Gen_i::AddObject(aStr, _this()) += ".CreateGroup("; + aStr += ElementTypeString(theElemType) + ", \"" + (char*)theName + "\")"; - // Update Python script - TCollection_AsciiString aStr (aSO->GetID()); - aStr += " = "; - SMESH_Gen_i::AddObject(aStr, _this()) += ".CreateGroup("; - aStr += ElementTypeString(theElemType) + ", \"" + (char*)theName + "\")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + SMESH_Gen_i::AddToCurrentPyScript(aStr); + } } return aNewGroup._retn(); @@ -668,15 +670,16 @@ SMESH::SMESH_GroupOnGeom_ptr SMESH_Mesh_i::CreateGroupFromGEOM (SMESH::ElementTy SALOMEDS::SObject_var aSO = _gen_i->PublishGroup(_gen_i->GetCurrentStudy(), _this(), aNewGroup, theGeomObj, theName); - - // Update Python script - TCollection_AsciiString aStr (aSO->GetID()); - aStr += " = "; - SMESH_Gen_i::AddObject(aStr, _this()) += ".CreateGroupFromGEOM("; - aStr += ElementTypeString(theElemType) + ", \"" + (char*)theName + "\", "; - SMESH_Gen_i::AddObject(aStr, theGeomObj) += ")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + if ( !aSO->_is_nil()) { + // Update Python script + TCollection_AsciiString aStr (aSO->GetID()); + aStr += " = "; + SMESH_Gen_i::AddObject(aStr, _this()) += ".CreateGroupFromGEOM("; + aStr += ElementTypeString(theElemType) + ", \"" + (char*)theName + "\", "; + SMESH_Gen_i::AddObject(aStr, theGeomObj) += ")"; + + SMESH_Gen_i::AddToCurrentPyScript(aStr); + } } }