Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/visu.git] / src / VISU_I / VISU_DumpPython.cc
index 91b8ef80fbdc5f9a9d214cca5d7dd3585dbea8ff..aea67bc018a99c96bcf6ac2e5e88351c5bb46f0f 100644 (file)
@@ -17,7 +17,7 @@
 //  License along with this library; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //  File   : VISU_DumpPython.cc
 #include "VISU_StreamLines_i.hh"
 #include "VISU_Plot3D_i.hh"
 #include "VISU_Table_i.hh"
+#include "VISU_GaussPoints_i.hh"
+#include "VISU_ScalarMapOnDeformedShape_i.hh"
+#include "VISU_ColoredPrs3dCache_i.hh"
+#include "VISU_ColoredPrs3dHolder_i.hh"
 
 #include "utilities.h"
 
 
 using namespace std;
 
-namespace VISU{
+namespace VISU
+{
+  //---------------------------------------------------------------------------
   static std::string PREFIX("  ");
 
   typedef std::map<std::string,std::string> TName2EntryMap;
   typedef std::map<std::string,std::string> TEntry2NameMap;
 
+
+  //---------------------------------------------------------------------------
   inline
   std::string
   GenerateName(std::string theName,
@@ -79,13 +87,18 @@ namespace VISU{
     return theName;
   }
 
-  struct TReplacePredicate{
+
+  //---------------------------------------------------------------------------
+  struct TReplacePredicate
+  {
     bool operator()(char theChar) const
     {
       return !(isdigit(theChar) || isalpha(theChar) || theChar == '_');
     }
   };
 
+
+  //---------------------------------------------------------------------------
   inline
   std::string
   GetName(SALOMEDS::SObject_ptr theSObject)
@@ -103,6 +116,8 @@ namespace VISU{
     return aName;
   }
 
+
+  //---------------------------------------------------------------------------
   inline
   std::string
   GenerateName(SALOMEDS::SObject_ptr theSObject,
@@ -111,11 +126,34 @@ namespace VISU{
   {
     std::string aName = GetName(theSObject);
 
-    return GenerateName(aName,theSObject,theName2EntryMap,theEntry2NameMap,'X');
+    return GenerateName(aName, theSObject, theName2EntryMap, theEntry2NameMap, 'X');
   }
 
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
+  inline
+  std::string
+  GetBoolean(bool theArgument)
+  {
+    if(theArgument)
+      return "True";
+
+    return "False";
+  }
+
+
+  //---------------------------------------------------------------------------
+  inline
+  std::string
+  GetColor(const SALOMEDS::Color& theColor)
+  {
+    std::ostringstream aStream;
+    aStream<<"SALOMEDS.Color("<<theColor.R<<", "<<theColor.G<<", "<<theColor.B<<")";
+    return aStream.str();
+  }
+
+
+  //---------------------------------------------------------------------------
   typedef void (*TDumpToPython)(SALOMEDS::Study_ptr theStudy,
                                CORBA::Boolean theIsPublished,
                                CORBA::Boolean& theIsValidScript,
@@ -139,18 +177,335 @@ namespace VISU{
               std::string thePrefix);
 
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
+  void
+  Prs3dToPython(VISU::Prs3d_i* theServant,
+               std::ostream& theStr,
+               const std::string& theName,
+               std::string thePrefix)
+  {
+    float x, y, z;
+    theServant->GetOffset(x,y,z);
+    theStr<<thePrefix<<theName<<".SetOffset("<<x<<", "<<y<<", "<<z<<")"<<endl;
+  }
+
+  //---------------------------------------------------------------------------
+  struct TColoredPrs3dFactory
+  {
+    virtual
+    std::string
+    operator()(std::ostream& theStr,
+              std::string thePrefix)
+    {
+
+      return thePrefix;
+    }
+  };
+
+
+  struct TCreateFromResult: TColoredPrs3dFactory
+  {
+    VISU::ColoredPrs3d_i* myServant;
+    std::string myConstructorName;
+    std::string myArgumentName;
+
+    SALOMEDS::SObject_var mySObject;
+    std::string myName;
+
+    TCreateFromResult(const SALOMEDS::SObject_var& theSObject,
+                     VISU::ColoredPrs3d_i* theServant,
+                     const std::string& theName,
+                     const std::string& theConstructorName,
+                     const std::string& theArgumentName):
+      myServant(theServant),
+      myConstructorName(theConstructorName),
+      myArgumentName(theArgumentName),
+      mySObject(theSObject),
+      myName(theName)
+    {}
+
+    virtual
+    std::string
+    operator()(std::ostream& theStr,
+              std::string thePrefix)
+    {
+      std::string aParam;
+      switch(myServant->GetEntity()){
+      case NODE:
+       aParam = "VISU.NODE";
+       break;
+      case EDGE:
+       aParam = "VISU.EDGE";
+       break;
+      case FACE:
+       aParam = "VISU.FACE";
+       break;
+      case CELL:
+       aParam = "VISU.CELL";
+       break;
+      }
+
+      theStr<<thePrefix<<myName<<" = aVisu."<<myConstructorName<<"("<<myArgumentName<<
+       ", '"<<myServant->GetCMeshName()<<"'"<<
+       ", "<<aParam<<
+       ", '"<<myServant->GetCFieldName()<<"'"<<
+       ", "<<myServant->GetTimeStampNumber()<<
+       ")"<<endl;
+      
+      theStr<<thePrefix<<"if "<<myName<<" != None:"<<endl;
+      thePrefix += PREFIX;
+      
+      // Add to Name->Object map
+      theStr<<thePrefix<<"aName2ObjectMap['"<<myName<<"'] = "<<myName<<endl;
+
+      // Set name (as this object could be renamed by user)
+      CORBA::String_var aNameInStudy = mySObject->GetName();
+      theStr<<thePrefix<<"visu.SetName("<<myName<<", '"<<aNameInStudy.in()<<"')"<<endl;
+
+      return thePrefix;
+    }
+  };
+
+
+  //---------------------------------------------------------------------------
+  std::string
+  ColoredPrs3dToPython(SALOMEDS::SObject_ptr theSObject,
+                      VISU::ColoredPrs3d_i* theServant,
+                      std::ostream& theStr,
+                      const std::string& theName,
+                      TColoredPrs3dFactory& thePrsFactory,
+                      std::string thePrefix)
+  {
+    thePrefix = thePrsFactory(theStr, thePrefix);
+
+    // Set parameters common for all Prs3d objects (offset values)
+    Prs3dToPython(theServant, theStr, theName, thePrefix);
+
+    theStr<<thePrefix<<theName<<".SetPosition("<<theServant->GetPosX()<<", "<<theServant->GetPosY()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetSize("<<theServant->GetWidth()<<", "<<theServant->GetHeight()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetNbColors("<<theServant->GetNbColors()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetLabels("<<theServant->GetLabels()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetTitle('"<<theServant->GetTitle()<<"')"<<endl;
+
+    std::string aParam;
+    switch(theServant->GetBarOrientation()){
+    case ColoredPrs3d::HORIZONTAL:
+      aParam = "VISU.ColoredPrs3d.HORIZONTAL";
+      break;
+    case ColoredPrs3d::VERTICAL:
+      aParam = "VISU.ColoredPrs3d.VERTICAL";
+      break;
+    }
+    theStr<<thePrefix<<theName<<".SetBarOrientation("<<aParam<<")"<<endl;
+
+    theStr<<thePrefix<<theName<<".SetScalarMode("<<theServant->GetScalarMode()<<")"<<endl;
+
+    if(theServant->IsRangeFixed())
+      theStr<<thePrefix<<theName<<".SetRange("<<theServant->GetMin()<<", "<<theServant->GetMax()<<")"<<endl;
+    else
+      theStr<<thePrefix<<theName<<".SetSourceRange()"<<endl;
+
+    const VISU::ColoredPrs3d_i::TGroupNames aGroupNames = theServant->GetGroupNames();
+    VISU::ColoredPrs3d_i::TGroupNames::const_iterator anIter = aGroupNames.begin();
+    for(; anIter != aGroupNames.end(); anIter++){
+      const std::string& aGroupName = *anIter;
+      theStr<<thePrefix<<theName<<".AddMeshOnGroup('"<<aGroupName<<"')"<<endl;
+    }
+    
+    return thePrefix;
+  }
+
+
+  //---------------------------------------------------------------------------
+  std::string
+  GaussPointsToPython(SALOMEDS::SObject_ptr theSObject,
+                     VISU::GaussPoints_i* theServant,
+                     std::ostream& theStr,
+                     const std::string& theName,
+                     TColoredPrs3dFactory& thePrsFactory,
+                     std::string thePrefix)
+  {
+    thePrefix = ColoredPrs3dToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
+    theStr<<thePrefix<<endl;
+
+    bool aBoolean = theServant->GetIsActiveLocalScalarBar();
+    theStr<<thePrefix<<theName<<".SetIsActiveLocalScalarBar("<<GetBoolean(aBoolean)<<")"<<endl;
+
+    if(aBoolean){
+      aBoolean = theServant->GetIsDispGlobalScalarBar();
+      theStr<<thePrefix<<theName<<".SetIsDispGlobalScalarBar("<<GetBoolean(aBoolean)<<")"<<endl;
+    }
+
+    theStr<<thePrefix<<theName<<".SetSpacing("<<theServant->GetSpacing()<<")"<<endl;
+
+    aBoolean = theServant->GetBiColor();
+    theStr<<thePrefix<<theName<<".SetBiColor("<<GetBoolean(aBoolean)<<")"<<endl;
+
+    aBoolean = theServant->GetIsDeformed();
+    theStr<<thePrefix<<theName<<".SetIsDeformed("<<GetBoolean(aBoolean)<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetScaleFactor("<<theServant->GetScaleFactor()<<")"<<endl;
+
+    std::string aParam;
+    switch(theServant->GetPrimitiveType()){
+    case VISU::GaussPoints::SPRITE :
+      aParam = "VISU.GaussPoints.SPRITE";
+      break;
+    case VISU::GaussPoints::POINT :
+      aParam = "VISU.GaussPoints.POINT";
+      break;
+    case VISU::GaussPoints::SPHERE :
+      aParam = "VISU.GaussPoints.SPHERE";
+      break;
+    }
+    theStr<<thePrefix<<theName<<".SetPrimitiveType("<<aParam<<")"<<endl;
+
+    theStr<<thePrefix<<theName<<".SetClamp("<<theServant->GetClamp()<<")"<<endl;
+
+    QString aMainTexture = theServant->GetQMainTexture();
+    QString anAlphaTexture = theServant->GetQAlphaTexture();
+    theStr<<thePrefix<<theName<<".SetTextures('"<<aMainTexture.latin1()<<"', '"<<anAlphaTexture.latin1()<<"')"<<endl;
+
+    theStr<<thePrefix<<theName<<".SetAlphaThreshold("<<theServant->GetAlphaThreshold()<<")"<<endl;
+
+    theStr<<thePrefix<<theName<<".SetResolution("<<theServant->GetResolution()<<")"<<endl;
+
+    theStr<<thePrefix<<theName<<".SetFaceLimit("<<theServant->GetFaceLimit()<<")"<<endl;
+
+    aBoolean = theServant->GetIsColored();
+    theStr<<thePrefix<<theName<<".SetIsColored("<<GetBoolean(aBoolean)<<")"<<endl;
+
+    if(aBoolean){
+      theStr<<thePrefix<<theName<<".SetMinSize("<<theServant->GetMinSize()<<")"<<endl;
+      theStr<<thePrefix<<theName<<".SetMaxSize("<<theServant->GetMaxSize()<<")"<<endl;
+    }else{
+      theStr<<thePrefix<<theName<<".SetColor("<<GetColor(theServant->GetColor())<<")"<<endl;
+      theStr<<thePrefix<<theName<<".SetGeomSize("<<theServant->GetGeomSize()<<")"<<endl;
+    }
+
+    theStr<<thePrefix<<theName<<".SetMagnification("<<theServant->GetMagnification()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetMagnificationIncrement("<<theServant->GetMagnificationIncrement()<<")"<<endl;
+
+    return thePrefix;
+  }
+
+
+  //---------------------------------------------------------------------------
   std::string
   ScalarMapToPython(SALOMEDS::SObject_ptr theSObject,
                    VISU::ScalarMap_i* theServant,
                    std::ostream& theStr,
-                   std::string& theName,
-                   const std::string& theConstructorName,
-                   const std::string& theArgumentName,
+                   const std::string& theName,
+                   TColoredPrs3dFactory& thePrsFactory,
                    std::string thePrefix)
   {
+    thePrefix = ColoredPrs3dToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
+    theStr<<thePrefix<<endl;
+
     std::string aParam;
-    switch(theServant->GetEntity()){
+    switch(theServant->GetScaling()){
+    case LINEAR:
+      aParam = "VISU.LINEAR";
+      break;
+    case LOGARITHMIC:
+      aParam = "VISU.LOGARITHMIC";
+      break;
+    }
+    theStr<<thePrefix<<theName<<".SetScaling("<<aParam<<")"<<endl;
+
+    return thePrefix;
+  }
+
+
+  //---------------------------------------------------------------------------
+  std::string
+  DeformedShapeToPython(SALOMEDS::SObject_ptr theSObject,
+                       VISU::DeformedShape_i* theServant,
+                       std::ostream& theStr,
+                       const std::string& theName,
+                       TColoredPrs3dFactory& thePrsFactory,
+                       std::string thePrefix)
+  {
+    thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
+    theStr<<thePrefix<<endl;
+
+    theStr<<thePrefix<<theName<<".SetScale("<<theServant->GetScale()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".ShowColored("<<GetBoolean(theServant->IsColored())<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetColor("<<GetColor(theServant->GetColor())<<")"<<endl;
+
+    return thePrefix;
+  }
+
+
+  //---------------------------------------------------------------------------
+  std::string
+  StreamLinesToPython(SALOMEDS::SObject_ptr theSObject,
+                     VISU::StreamLines_i* theServant,
+                     std::ostream& theStr,
+                     TEntry2NameMap& theEntry2NameMap,
+                     const std::string& theName,
+                     TColoredPrs3dFactory& thePrsFactory,
+                     std::string thePrefix)
+  {
+    thePrefix = DeformedShapeToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
+    theStr<<thePrefix<<endl;
+    
+    std::string aParam;
+    switch(theServant->GetDirection()){
+    case StreamLines::FORWARD:
+      aParam = "VISU.StreamLines.FORWARD";
+      break;
+    case StreamLines::BACKWARD:
+      aParam = "VISU.StreamLines.BACKWARD";
+      break;
+    case StreamLines::BOTH:
+      aParam = "VISU.StreamLines.BOTH";
+      break;
+    }
+    
+    theStr<<thePrefix<<"aPrs3d = None"<<endl;
+    VISU::Prs3d_var aPrs3d = theServant->GetSource();
+    if(!CORBA::is_nil(aPrs3d)){
+      if(Prs3d_i* aServant3d = dynamic_cast<Prs3d_i*>(GetServant(aPrs3d).in())){
+       SALOMEDS::SObject_var aSObject = aServant3d->GetSObject();
+       CORBA::String_var anID = aSObject->GetID();
+       std::string anArg = theEntry2NameMap[anID.in()];
+       theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<anArg<<"'):"<<endl;
+       thePrefix += PREFIX;
+       theStr<<thePrefix<<"aPrs3d = aName2ObjectMap['"<<anArg<<"']"<<endl;
+      }
+    }
+    
+    theStr<<thePrefix<<theName<<".SetParams("<<
+      theServant->GetIntegrationStep()<<", "<<
+      theServant->GetPropagationTime()<<", "<<
+      theServant->GetStepLength()<<", "<<
+      "aPrs3d"<<", "<<
+      theServant->GetUsedPoints()<<", "<<
+      aParam<<
+      ")"<<endl;
+    
+    return thePrefix;
+  }
+
+
+  //---------------------------------------------------------------------------
+  std::string
+  ScalarMapOnDeformedShapeToPython(SALOMEDS::SObject_ptr theSObject,
+                                  VISU::ScalarMapOnDeformedShape_i* theServant,
+                                  std::ostream& theStr,
+                                  const std::string& theName,
+                                  TColoredPrs3dFactory& thePrsFactory,
+                                  std::string thePrefix)
+  {
+    thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
+    theStr<<thePrefix<<endl;
+
+    theStr<<thePrefix<<theName<<".SetRange("<<theServant->GetMin()<<", "<<theServant->GetMax()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetScale("<<theServant->GetScale()<<")"<<endl;
+
+    std::string aParam;
+    VISU::Entity anEntity = theServant->GetScalarEntity();
+    switch(anEntity){
     case NODE:
       aParam = "VISU.NODE";
       break;
@@ -164,73 +519,220 @@ namespace VISU{
       aParam = "VISU.CELL";
       break;
     }
-
-    theStr<<thePrefix<<theName<<" = aVisu."<<theConstructorName<<"("<<theArgumentName<<
-      ",'"<<theServant->GetMeshName()<<"'"<<
-      ","<<aParam<<
-      ",'"<<theServant->GetFieldName()<<"'"<<
-      ","<<theServant->GetIteration()<<
+    
+    CORBA::String_var aFieldName = theServant->GetScalarFieldName();
+    CORBA::Long aTimeStampNumber = theServant->GetScalarTimeStampNumber();
+    
+    theStr<<thePrefix<<theName<<".SetScalarField("<<
+      aParam<<", "<<
+      "'"<<aFieldName<<"', "<<
+      aTimeStampNumber<<
       ")"<<endl;
 
-    theStr<<thePrefix<<"if "<<theName<<":"<<endl;
-    thePrefix += PREFIX;
+    return thePrefix;
+  }
 
-    theStr<<thePrefix<<"aName2ObjectMap['"<<theName<<"'] = "<<theName<<endl;
 
-    theStr<<thePrefix<<theName<<".SetScalarMode("<<theServant->GetScalarMode()<<")"<<endl;
+  //---------------------------------------------------------------------------
+  std::string
+  VectorsToPython(SALOMEDS::SObject_ptr theSObject,
+                 VISU::Vectors_i* theServant,
+                 std::ostream& theStr,
+                 const std::string& theName,
+                 TColoredPrs3dFactory& thePrsFactory,
+                 std::string thePrefix)
+  {
+    thePrefix = DeformedShapeToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
+    theStr<<thePrefix<<endl;
 
-    switch(theServant->GetScaling()){
-    case LINEAR:
-      aParam = "VISU.LINEAR";
+    theStr<<thePrefix<<theName<<".SetLineWidth("<<theServant->GetLineWidth()<<")"<<endl;
+
+    std::string aParam;
+    switch(theServant->GetGlyphType()){
+    case Vectors::ARROW:
+      aParam = "VISU.Vectors.ARROW";
       break;
-    case LOGARITHMIC:
-      aParam = "VISU.LOGARITHMIC";
+    case Vectors::CONE2:
+      aParam = "VISU.Vectors.CONE2";
+      break;
+    case Vectors::CONE6:
+      aParam = "VISU.Vectors.CONE6";
+      break;
+    case Vectors::NONE:
+      aParam = "VISU.Vectors.NONE";
       break;
     }
-    theStr<<thePrefix<<theName<<".SetScaling("<<aParam<<")"<<endl;
-    theStr<<thePrefix<<theName<<".SetRange("<<theServant->GetMin()<<","<<theServant->GetMax()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetGlyphType("<<aParam<<")"<<endl;
+    
+    switch(theServant->GetGlyphPos()){
+    case Vectors::CENTER:
+      aParam = "VISU.Vectors.CENTER";
+      break;
+    case Vectors::TAIL:
+      aParam = "VISU.Vectors.TAIL";
+      break;
+    case Vectors::HEAD:
+      aParam = "VISU.Vectors.HEAD";
+      break;
+    }
+    theStr<<thePrefix<<theName<<".SetGlyphPos("<<aParam<<")"<<endl;
+    
+    return thePrefix;
+  }
 
-    switch(theServant->GetBarOrientation()){
-    case ScalarMap::HORIZONTAL:
-      aParam = "VISU.ScalarMap.HORIZONTAL";
+
+  //---------------------------------------------------------------------------
+  std::string
+  IsoSurfacesToPython(SALOMEDS::SObject_ptr theSObject,
+                     VISU::IsoSurfaces_i* theServant,
+                     std::ostream& theStr,
+                     const std::string& theName,
+                     TColoredPrs3dFactory& thePrsFactory,
+                     std::string thePrefix)
+  {
+    thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
+    theStr<<thePrefix<<endl;
+
+    theStr<<thePrefix<<theName<<".SetNbSurfaces("<<theServant->GetNbSurfaces()<<")"<<endl;
+
+    return thePrefix;
+  }
+
+
+  //---------------------------------------------------------------------------
+  std::string
+  CutPlanesToPython(SALOMEDS::SObject_ptr theSObject,
+                   VISU::CutPlanes_i* theServant,
+                   std::ostream& theStr,
+                   const std::string& theName,
+                   TColoredPrs3dFactory& thePrsFactory,
+                   std::string thePrefix)
+  {
+    thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
+    theStr<<thePrefix<<endl;
+
+    std::string aParam;
+    switch(theServant->GetOrientationType()){
+    case CutPlanes::XY:
+      aParam = "VISU.CutPlanes.XY";
+      break;
+    case CutPlanes::YZ:
+      aParam = "VISU.CutPlanes.YZ";
       break;
-    case ScalarMap::VERTICAL:
-      aParam = "VISU.ScalarMap.VERTICAL";
+    case CutPlanes::ZX:
+      aParam = "VISU.CutPlanes.ZX";
       break;
     }
-    theStr<<thePrefix<<theName<<".SetBarOrientation("<<aParam<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetOrientation("<<aParam<<", "<<theServant->GetRotateX()<<", "<<theServant->GetRotateY()<<")"<<endl;
+    
+    theStr<<thePrefix<<theName<<".SetDisplacement("<<theServant->GetDisplacement()<<")"<<endl;
+    CORBA::Long aNbPlanes = theServant->GetNbPlanes();
+    theStr<<thePrefix<<theName<<".SetNbPlanes("<<aNbPlanes<<")"<<endl;
+    
+    for(CORBA::Long anId = 0; anId < aNbPlanes; anId++){
+      if(!theServant->IsDefault(anId))
+       theStr<<thePrefix<<theName<<".SetPlanePosition("<<anId<<", "<<theServant->GetPlanePosition(anId)<<")"<<endl;
+    }
 
-    theStr<<thePrefix<<theName<<".SetPosition("<<theServant->GetPosX()<<","<<theServant->GetPosY()<<")"<<endl;
-    theStr<<thePrefix<<theName<<".SetSize("<<theServant->GetWidth()<<","<<theServant->GetHeight()<<")"<<endl;
-    theStr<<thePrefix<<theName<<".SetNbColors("<<theServant->GetNbColors()<<")"<<endl;
-    theStr<<thePrefix<<theName<<".SetLabels("<<theServant->GetLabels()<<")"<<endl;
-    theStr<<thePrefix<<theName<<".SetTitle('"<<theServant->GetTitle()<<"')"<<endl;
+    return thePrefix;
+  }
 
+
+  //---------------------------------------------------------------------------
+  std::string
+  CutLinesToPython(SALOMEDS::SObject_ptr theSObject,
+                  VISU::CutLines_i* theServant,
+                  std::ostream& theStr,
+                  const std::string& theName,
+                  TColoredPrs3dFactory& thePrsFactory,
+                  std::string thePrefix)
+  {
+    thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
+    theStr<<thePrefix<<endl;
+
+    std::string aParam;
+    switch(theServant->GetOrientationType()){
+    case CutPlanes::XY:
+      aParam = "VISU.CutPlanes.XY";
+      break;
+    case CutPlanes::YZ:
+      aParam = "VISU.CutPlanes.YZ";
+      break;
+    case CutPlanes::ZX:
+      aParam = "VISU.CutPlanes.ZX";
+      break;
+    }
+    theStr<<thePrefix<<theName<<".SetOrientation("<<aParam<<", "<<theServant->GetRotateX()<<", "<<theServant->GetRotateY()<<")"<<endl;
+    
+    switch(theServant->GetOrientationType2()){
+    case CutPlanes::XY:
+      aParam = "VISU.CutPlanes.XY";
+      break;
+    case CutPlanes::YZ:
+      aParam = "VISU.CutPlanes.YZ";
+      break;
+    case CutPlanes::ZX:
+      aParam = "VISU.CutPlanes.ZX";
+      break;
+    }
+    theStr<<thePrefix<<theName<<".SetOrientation2("<<aParam<<", "<<theServant->GetRotateX2()<<", "<<theServant->GetRotateY2()<<")"<<endl;
+    
+    theStr<<thePrefix<<theName<<".SetDisplacement("<<theServant->GetDisplacement()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetDisplacement2("<<theServant->GetDisplacement2()<<")"<<endl;
+    
+    if(!theServant->IsDefault())
+      theStr<<thePrefix<<theName<<".SetBasePlanePosition("<<theServant->GetBasePlanePosition()<<")"<<endl;
+    
+    CORBA::Boolean aUseAbsLength = theServant->IsUseAbsoluteLength();
+    theStr<<thePrefix<<theName<<".SetUseAbsoluteLength("<<aUseAbsLength<<")"<<endl;
+    
+    CORBA::Long aNbLines = theServant->GetNbLines();
+    theStr<<thePrefix<<theName<<".SetNbLines("<<aNbLines<<")"<<endl;
+    for(CORBA::Long anId = 0; anId < aNbLines; anId++){
+      if(!theServant->IsDefaultPosition(anId))
+       theStr<<thePrefix<<theName<<".SetLinePosition("<<anId<<", "<<theServant->GetLinePosition(anId)<<")"<<endl;
+    }
+    
     return thePrefix;
   }
 
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
   std::string
-  DeformedShapeToPython(SALOMEDS::SObject_ptr theSObject,
-                       VISU::DeformedShape_i* theServant,
-                       std::ostream& theStr,
-                       std::string& theName,
-                       const std::string& theConstructorName,
-                       const std::string& theArgumentName,
-                       std::string thePrefix)
+  Plot3DToPython(SALOMEDS::SObject_ptr theSObject,
+                VISU::Plot3D_i* theServant,
+                std::ostream& theStr,
+                const std::string& theName,
+                TColoredPrs3dFactory& thePrsFactory,
+                std::string thePrefix)
   {
-    thePrefix = ScalarMapToPython(theSObject,theServant,theStr,theName,theConstructorName,theArgumentName,thePrefix);
-    theStr<<thePrefix<<theName<<".SetScale("<<theServant->GetScale()<<")"<<endl;
-    theStr<<thePrefix<<theName<<".ShowColored("<<theServant->IsColored()<<")"<<endl;
-    SALOMEDS::Color aColor = theServant->GetColor();
-    theStr<<thePrefix<<theName<<".SetColor(SALOMEDS.Color("<<
-      aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
+    thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
+    theStr<<thePrefix<<endl;
+
+    std::string aParam;
+    switch(theServant->GetOrientationType()){
+    case CutPlanes::XY: 
+      aParam = "VISU.Plot3D.XY"; 
+      break;
+    case CutPlanes::YZ: 
+      aParam = "VISU.Plot3D.YZ"; 
+      break;
+    case CutPlanes::ZX: 
+      aParam = "VISU.Plot3D.ZX"; 
+      break;
+    }
+    theStr<<thePrefix<<theName<<".SetOrientation("<<aParam<<", "<<theServant->GetRotateX()<<", "<<theServant->GetRotateY()<<")"<<endl;
+
+    theStr<<thePrefix<<theName<<".SetPlanePosition("<<theServant->GetPlanePosition()<<", "<<theServant->IsPositionRelative()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetScaleFactor("<<theServant->GetScaleFactor()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetContourPrs("<<theServant->GetIsContourPrs()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetNbOfContours("<<theServant->GetNbOfContours()<<")"<<endl;
 
     return thePrefix;
   }
 
-  //===========================================================================
+
+  //---------------------------------------------------------------------------
   // declaration
   void DumpChildrenToPython(SALOMEDS::Study_ptr theStudy,
                            CORBA::Boolean theIsPublished,
@@ -242,7 +744,7 @@ namespace VISU{
                            std::string theArgumentName,
                            std::string thePrefix);
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
   template<class TTableAttr>
   void
   TableAttrToPython(SALOMEDS::Study_ptr theStudy,
@@ -259,12 +761,12 @@ namespace VISU{
   {
     SALOMEDS::GenericAttribute_var anAttr;
     SALOMEDS::SObject_var aFatherSObject = theSObject->GetFather();
-    if(aFatherSObject->FindAttribute(anAttr,"AttributeComment")){
-      SALOMEDS::AttributeComment_var aComment =
-       SALOMEDS::AttributeComment::_narrow(anAttr);
+    if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){
+      SALOMEDS::AttributeString_var aComment =
+       SALOMEDS::AttributeString::_narrow(anAttr);
       CORBA::String_var aValue = aComment->Value();
       Storable::TRestoringMap aMap;
-      Storable::StrToMap(aValue.in(),aMap);
+      Storable::StringToMap(aValue.in(),aMap);
       bool anIsExist;
       QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
       if(anIsExist){
@@ -279,9 +781,10 @@ namespace VISU{
     theStr<<thePrefix<<"if "<<aSObjectName<<":"<<endl;
     thePrefix += PREFIX;
 
+    theStr<<thePrefix<<"aBuilder.SetName("<<aSObjectName<<", \""<<theSObject->GetName()<<"\")"<<endl; // Fix for IPAL13165
     std::string aName = "aTableAttr";
     theStr<<thePrefix<<aName<<" = aBuilder.FindOrCreateAttribute("<<
-      aSObjectName<<",'"<<theAttrName<<"')"<<endl;
+      aSObjectName<<", '"<<theAttrName<<"')"<<endl;
 
     theStr<<thePrefix<<"if "<<aName<<":"<<endl;
     std::string aPrefix = thePrefix;
@@ -350,7 +853,7 @@ namespace VISU{
                   << aName << "_cTitles )" << endl;
 
     if(theSObject->FindAttribute(anAttr,"AttributeIOR")){
-      theStr<<endl;
+      theStr<<thePrefix<<endl;
       std::string aName = "aTable";
       theStr<<thePrefix<<"anID = "<<aSObjectName<<".GetID()"<<endl;
       theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
@@ -359,6 +862,10 @@ namespace VISU{
       theStr<<thePrefix<<"if "<<aName<<":"<<endl;
       std::string aPrefix2 = thePrefix + PREFIX;
 
+      // Set name (as this object could be renamed by user)
+      CORBA::String_var aNameInStudy = theSObject->GetName();
+      theStr<<aPrefix2<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 1"<<endl;
+
       DumpChildrenToPython(theStudy,
                           theIsPublished,
                           theIsValidScript,
@@ -377,7 +884,7 @@ namespace VISU{
   }
 
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
   void
   DumpChildrenToPython(SALOMEDS::Study_ptr theStudy,
                       CORBA::Boolean theIsPublished,
@@ -405,7 +912,7 @@ namespace VISU{
   }
 
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
   void
   DumpTableAttrToPython(SALOMEDS::Study_ptr theStudy,
                        CORBA::Boolean theIsPublished,
@@ -452,8 +959,9 @@ namespace VISU{
     }
   }
 
+  
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
   void
   DumpToPython(SALOMEDS::Study_ptr theStudy,
               CORBA::Boolean theIsPublished,
@@ -466,34 +974,81 @@ namespace VISU{
               std::string thePrefix)
   {
     std::string aName = GetName(theSObject);
-    if(aName == "")
+    if (aName == "")
       return;
 
+    CORBA::String_var anID = theSObject->GetID();
+    CORBA::String_var aNameInStudy = theSObject->GetName();
+
     CORBA::Object_var anObj = SObjectToObject(theSObject);
-    if(!CORBA::is_nil(anObj)){
+    if (!CORBA::is_nil(anObj)) {
       VISU::Base_var aBase = VISU::Base::_narrow(anObj);
       if(!CORBA::is_nil(aBase)){
-       std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap);
-       CORBA::String_var anID = theSObject->GetID();
+       std::string aName = GenerateName(theSObject, theName2EntryMap, theEntry2NameMap);
 
         VISU::VISUType aType = aBase->GetType();
         switch(aType){
         case VISU::TRESULT:
           if(Result_i* aServant = dynamic_cast<Result_i*>(GetServant(anObj).in())){
-           std::string aFileName = aServant->GetFileName();
+           std::string aFileName = aServant->GetInitFileName();
            Result_i::ECreationId anId = aServant->GetCreationId();
            if(anId == Result_i::eImportFile || anId == Result_i::eCopyAndImportFile){
              switch(anId){
              case Result_i::eImportFile:
-               theStr<<thePrefix<<aName<<" = aVisu.ImportFile('"<<aFileName<<"')"<<endl;
+               theStr<<thePrefix<<aName<<" = aVisu.CreateResult('"<<aFileName<<"')"<<endl;
+
+               theStr<<thePrefix<<aName<<".SetBuildGroups("<<
+                 GetBoolean(aServant->IsGroupsDone())<<")"<<
+                 endl;
+
+               theStr<<thePrefix<<aName<<".SetBuildFields("<<
+                 GetBoolean(aServant->IsFieldsDone())<<", "<<
+                 GetBoolean(aServant->IsMinMaxDone())<<")"<<
+                 endl;
+
+               theStr<<thePrefix<<aName<<".Build(False, True)"<<endl;
+
+               theStr<<thePrefix<<"if "<<aName<<".IsDone() :"<<endl;
                break;
              case Result_i::eCopyAndImportFile:
                theStr<<thePrefix<<aName<<" = aVisu.CopyAndImportFile('"<<aFileName<<"')"<<endl;
+               theStr<<thePrefix<<"if "<<aName<<":"<<endl;
                break;
              }
 
-             theStr<<thePrefix<<"if "<<aName<<":"<<endl;
              thePrefix += PREFIX;
+             {
+               VISU::Result::EntityNames_var aMeshNames = aServant->GetMeshNames();
+               if (aMeshNames->length() > 0) {
+                 for(size_t aMeshId = 0; aMeshId < aMeshNames->length(); aMeshId++){
+                   CORBA::String_var aMeshName = aMeshNames[aMeshId];
+                   VISU::Result::EntityNames_var aParts = aServant->GetPartNames(aMeshName);
+                   if (aParts->length() > 0) {
+                     for(size_t aPartId = 0; aPartId < aParts->length(); aPartId++){
+                       CORBA::String_var aPart = aParts[aPartId];
+                       VISU::Result::Resolution aResolution = aServant->GetResolution(aMeshName, aPart);
+                       std::string aParam;
+                       switch(aResolution){
+                       case VISU::Result::FULL:
+                         aParam = "VISU.Result.FULL";
+                         break;
+                       case VISU::Result::MEDIUM:
+                         aParam = "VISU.Result.MEDIUM";
+                         break;
+                       case VISU::Result::LOW:
+                         aParam = "VISU.Result.LOW";
+                         break;
+                       case VISU::Result::HIDDEN:
+                         aParam = "VISU.Result.HIDDEN";
+                         break;
+                       }
+                       theStr<<thePrefix<<aName<<".SetResolution('"<<aMeshName.in()<<"', '"<<aPart.in()<<"', "<<aParam<<")"<<endl;
+                     }
+                     theStr<<thePrefix<<endl;
+                   }
+                 }
+               }
+             }
 
              theArgumentName = aName;
              DumpChildrenToPython(theStudy,
@@ -554,7 +1109,7 @@ namespace VISU{
           }
           return;
         case VISU::TMESH:
-          if(Mesh_i* aServant = dynamic_cast<Mesh_i*>(GetServant(anObj).in())){
+          if(Mesh_i* aServant = dynamic_cast<Mesh_i*>(GetServant(anObj).in())){            
            VISU::Entity anEntity = aServant->GetEntity();
            const std::string& aSubMeshName = aServant->GetSubMeshName();
            if(anEntity >= 0){
@@ -576,38 +1131,46 @@ namespace VISU{
 
              if(aSubMeshName == "")
                theStr<<thePrefix<<aName<<" = aVisu.MeshOnEntity("<<theArgumentName<<
-                 ",'"<<aServant->GetMeshName()<<"'"<<
-                 ","<<aParam<<
+                 ", '"<<aServant->GetCMeshName()<<"'"<<
+                 ", "<<aParam<<
                  ")"<<endl;
              else
                theStr<<thePrefix<<aName<<" = aVisu.FamilyMeshOnEntity("<<theArgumentName<<
-                 ",'"<<aServant->GetMeshName()<<"'"<<
-                 ","<<aParam<<
-                 ",'"<<aSubMeshName<<"'"<<
+                 ", '"<<aServant->GetCMeshName()<<"'"<<
+                 ", "<<aParam<<
+                 ", '"<<aSubMeshName<<"'"<<
                  ")"<<endl;
            }else
              theStr<<thePrefix<<aName<<" = aVisu.GroupMesh("<<theArgumentName<<
-               ",'"<<aServant->GetMeshName()<<"'"<<
-               ",'"<<aSubMeshName<<"'"<<
+               ", '"<<aServant->GetCMeshName()<<"'"<<
+               ", '"<<aSubMeshName<<"'"<<
                ")"<<endl;
 
            theStr<<thePrefix<<"if "<<aName<<":"<<endl;
            thePrefix += PREFIX;
 
+           // Add to Name->Object map
            theStr<<thePrefix<<"aName2ObjectMap['"<<aName<<"'] = "<<aName<<endl;
 
+           // Set name (as this object could be renamed by user)
+           theStr<<thePrefix<<"visu.SetName("<<aName<<", '"<<aNameInStudy.in()<<"')"<<endl;
+
+           // Set parameters common for all Prs3d objects (offset values)
+           Prs3dToPython(aServant,theStr,aName,thePrefix);
+
+           // Set presentation parameters
            SALOMEDS::Color aColor;
            aColor = aServant->GetCellColor();
            theStr<<thePrefix<<aName<<".SetCellColor(SALOMEDS.Color("<<
-             aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
+             aColor.R<<", "<<aColor.G<<", "<<aColor.B<<"))"<<endl;
 
            aColor = aServant->GetNodeColor();
            theStr<<thePrefix<<aName<<".SetNodeColor(SALOMEDS.Color("<<
-             aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
+             aColor.R<<", "<<aColor.G<<", "<<aColor.B<<"))"<<endl;
 
            aColor = aServant->GetLinkColor();
            theStr<<thePrefix<<aName<<".SetLinkColor(SALOMEDS.Color("<<
-             aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
+             aColor.R<<", "<<aColor.G<<", "<<aColor.B<<"))"<<endl;
 
            std::string aParam;
            switch(aServant->GetPresentationType()){
@@ -631,7 +1194,7 @@ namespace VISU{
              break;
            }
            theStr<<thePrefix<<aName<<".SetPresentationType("<<aParam<<")"<<endl;
-           theStr<<endl;
+           theStr<<thePrefix<<endl;
 
            DumpChildrenToPython(theStudy,
                                 theIsPublished,
@@ -649,179 +1212,57 @@ namespace VISU{
           break;
         case VISU::TSCALARMAP:
           if(ScalarMap_i* aServant = dynamic_cast<ScalarMap_i*>(GetServant(anObj).in())){
-           thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"ScalarMapOnField",theArgumentName,thePrefix);
+           TCreateFromResult aPrsFactory(theSObject, aServant, aName, "ScalarMapOnField", theArgumentName);
+           thePrefix = ScalarMapToPython(theSObject, aServant, theStr,aName, aPrsFactory, thePrefix);
            theStr<<thePrefix<<"pass"<<endl<<endl;
           }
           return;
         case VISU::TDEFORMEDSHAPE:
           if(DeformedShape_i* aServant = dynamic_cast<DeformedShape_i*>(GetServant(anObj).in())){
-           thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"DeformedShapeOnField",theArgumentName,thePrefix);
+           TCreateFromResult aPrsFactory(theSObject, aServant, aName, "DeformedShapeOnField", theArgumentName);
+           thePrefix = DeformedShapeToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
            theStr<<thePrefix<<"pass"<<endl<<endl;
           }
           return;
         case VISU::TSTREAMLINES:
           if(StreamLines_i* aServant = dynamic_cast<StreamLines_i*>(GetServant(anObj).in())){
-           thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"StreamLinesOnField",theArgumentName,thePrefix);
-
-           std::string aParam;
-           switch(aServant->GetDirection()){
-           case StreamLines::FORWARD:
-             aParam = "VISU.StreamLines.FORWARD";
-             break;
-           case StreamLines::BACKWARD:
-             aParam = "VISU.StreamLines.BACKWARD";
-             break;
-           case StreamLines::BOTH:
-             aParam = "VISU.StreamLines.BOTH";
-             break;
-           }
-
-           theStr<<thePrefix<<"aPrs3d = None"<<endl;
-           VISU::Prs3d_var aPrs3d = aServant->GetSource();
-           if(!CORBA::is_nil(aPrs3d)){
-             if(Prs3d_i* aServant3d = dynamic_cast<Prs3d_i*>(GetServant(aPrs3d).in())){
-               SALOMEDS::SObject_var aSObject = aServant3d->GetSObject();
-               CORBA::String_var anID = aSObject->GetID();
-               std::string anArg = theEntry2NameMap[anID.in()];
-               theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<anArg<<"'):"<<endl;
-               thePrefix += PREFIX;
-               theStr<<thePrefix<<"aPrs3d = aName2ObjectMap['"<<anArg<<"']"<<endl;
-             }
-           }
-
-           theStr<<thePrefix<<aName<<".SetParams("<<
-             aServant->GetIntegrationStep()<<","<<
-             aServant->GetPropagationTime()<<","<<
-             aServant->GetStepLength()<<","<<
-             "aPrs3d"<<","<<
-             aServant->GetUsedPoints()<<","<<
-             aParam<<
-             ")"<<endl;
-
+           TCreateFromResult aPrsFactory(theSObject, aServant, aName, "StreamLinesOnField", theArgumentName);
+           thePrefix = StreamLinesToPython(theSObject, aServant, theStr, theEntry2NameMap, aName, aPrsFactory, thePrefix);
+           theStr<<thePrefix<<"pass"<<endl<<endl;
+          }
+          return;
+        case VISU::TSCALARMAPONDEFORMEDSHAPE:
+          if(ScalarMapOnDeformedShape_i* aServant = dynamic_cast<ScalarMapOnDeformedShape_i*>(GetServant(anObj).in())){
+           TCreateFromResult aPrsFactory(theSObject, aServant, aName, "ScalarMapOnDeformedShapeOnField", theArgumentName);
+           thePrefix = ScalarMapOnDeformedShapeToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
            theStr<<thePrefix<<"pass"<<endl<<endl;
           }
           return;
         case VISU::TVECTORS:
           if(Vectors_i* aServant = dynamic_cast<Vectors_i*>(GetServant(anObj).in())){
-           thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"VectorsOnField",theArgumentName,thePrefix);
-
-           theStr<<thePrefix<<aName<<".SetLineWidth("<<aServant->GetLineWidth()<<")"<<endl;
-
-           std::string aParam;
-           switch(aServant->GetGlyphType()){
-           case Vectors::ARROW:
-             aParam = "VISU.Vectors.ARROW";
-             break;
-           case Vectors::CONE2:
-             aParam = "VISU.Vectors.CONE2";
-             break;
-           case Vectors::CONE6:
-             aParam = "VISU.Vectors.CONE6";
-             break;
-           case Vectors::NONE:
-             aParam = "VISU.Vectors.NONE";
-             break;
-           }
-           theStr<<thePrefix<<aName<<".SetGlyphType("<<aParam<<")"<<endl;
-
-           switch(aServant->GetGlyphPos()){
-           case Vectors::CENTER:
-             aParam = "VISU.Vectors.CENTER";
-             break;
-           case Vectors::TAIL:
-             aParam = "VISU.Vectors.TAIL";
-             break;
-           case Vectors::HEAD:
-             aParam = "VISU.Vectors.HEAD";
-             break;
-           }
-           theStr<<thePrefix<<aName<<".SetGlyphPos("<<aParam<<")"<<endl;
-
+           TCreateFromResult aPrsFactory(theSObject, aServant, aName, "VectorsOnField", theArgumentName);
+           thePrefix = VectorsToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
            theStr<<thePrefix<<"pass"<<endl<<endl;
           }
           return;
-        case VISU::TISOSURFACE:
+        case VISU::TISOSURFACES:
           if(IsoSurfaces_i* aServant = dynamic_cast<IsoSurfaces_i*>(GetServant(anObj).in())){
-           thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"IsoSurfacesOnField",theArgumentName,thePrefix);
-           theStr<<thePrefix<<aName<<".SetNbSurfaces("<<aServant->GetNbSurfaces()<<")"<<endl;
+           TCreateFromResult aPrsFactory(theSObject, aServant, aName, "IsoSurfacesOnField", theArgumentName);
+           thePrefix = IsoSurfacesToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
            theStr<<thePrefix<<"pass"<<endl<<endl;
           }
           return;
         case VISU::TCUTPLANES:
           if(CutPlanes_i* aServant = dynamic_cast<CutPlanes_i*>(GetServant(anObj).in())){
-           thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"CutPlanesOnField",theArgumentName,thePrefix);
-
-           std::string aParam;
-           switch(aServant->GetOrientationType()){
-           case CutPlanes::XY:
-             aParam = "VISU.CutPlanes.XY";
-             break;
-           case CutPlanes::YZ:
-             aParam = "VISU.CutPlanes.YZ";
-             break;
-           case CutPlanes::ZX:
-             aParam = "VISU.CutPlanes.ZX";
-             break;
-           }
-           theStr<<thePrefix<<aName<<".SetOrientation("<<aParam<<","<<aServant->GetRotateX()<<","<<aServant->GetRotateY()<<")"<<endl;
-
-           theStr<<thePrefix<<aName<<".SetDisplacement("<<aServant->GetDisplacement()<<")"<<endl;
-           CORBA::Long aNbPlanes = aServant->GetNbPlanes();
-           theStr<<thePrefix<<aName<<".SetNbPlanes("<<aNbPlanes<<")"<<endl;
-
-           for(CORBA::Long anId = 0; anId < aNbPlanes; anId++){
-             if(!aServant->IsDefault(anId))
-               theStr<<thePrefix<<aName<<".SetPlanePosition("<<anId<<","<<aServant->GetPlanePosition(anId)<<")"<<endl;
-           }
-
+           TCreateFromResult aPrsFactory(theSObject, aServant, aName, "CutPlanesOnField", theArgumentName);
+           thePrefix = CutPlanesToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
            theStr<<thePrefix<<"pass"<<endl<<endl;
           }
           return;
         case VISU::TCUTLINES:
           if(CutLines_i* aServant = dynamic_cast<CutLines_i*>(GetServant(anObj).in())){
-           thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"CutLinesOnField",theArgumentName,thePrefix);
-
-           std::string aParam;
-           switch(aServant->GetOrientationType()){
-           case CutPlanes::XY:
-             aParam = "VISU.CutPlanes.XY";
-             break;
-           case CutPlanes::YZ:
-             aParam = "VISU.CutPlanes.YZ";
-             break;
-           case CutPlanes::ZX:
-             aParam = "VISU.CutPlanes.ZX";
-             break;
-           }
-           theStr<<thePrefix<<aName<<".SetOrientation("<<aParam<<","<<aServant->GetRotateX()<<","<<aServant->GetRotateY()<<")"<<endl;
-
-           switch(aServant->GetOrientationType2()){
-           case CutPlanes::XY:
-             aParam = "VISU.CutPlanes.XY";
-             break;
-           case CutPlanes::YZ:
-             aParam = "VISU.CutPlanes.YZ";
-             break;
-           case CutPlanes::ZX:
-             aParam = "VISU.CutPlanes.ZX";
-             break;
-           }
-           theStr<<thePrefix<<aName<<".SetOrientation2("<<aParam<<","<<aServant->GetRotateX2()<<","<<aServant->GetRotateY2()<<")"<<endl;
-
-           theStr<<thePrefix<<aName<<".SetDisplacement("<<aServant->GetDisplacement()<<")"<<endl;
-           theStr<<thePrefix<<aName<<".SetDisplacement2("<<aServant->GetDisplacement2()<<")"<<endl;
-
-           if(!aServant->IsDefault())
-             theStr<<thePrefix<<aName<<".SetBasePlanePosition("<<aServant->GetBasePlanePosition()<<")"<<endl;
-
-           CORBA::Long aNbLines = aServant->GetNbLines();
-           theStr<<thePrefix<<aName<<".SetNbLines("<<aNbLines<<")"<<endl;
-           for(CORBA::Long anId = 0; anId < aNbLines; anId++){
-             if(!aServant->IsDefaultPosition(anId))
-               theStr<<thePrefix<<aName<<".SetLinePosition("<<anId<<","<<aServant->GetLinePosition(anId)<<")"<<endl;
-           }
-
-           theStr<<endl;
+           TCreateFromResult aPrsFactory(theSObject, aServant, aName, "CutLinesOnField", theArgumentName);
+           thePrefix = CutLinesToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
 
            theArgumentName = aName;
            DumpChildrenToPython(theStudy,
@@ -839,35 +1280,37 @@ namespace VISU{
           return;
         case VISU::TPLOT3D:
           if (Plot3D_i* aServant = dynamic_cast<Plot3D_i*>(GetServant(anObj).in())) {
-            thePrefix = ScalarMapToPython(theSObject, aServant, theStr, aName,
-                                         "Plot3DOnField", theArgumentName, thePrefix);
-
-           std::string aParam;
-           switch(aServant->GetOrientationType()){
-           case CutPlanes::XY: aParam = "VISU.Plot3D.XY"; break;
-           case CutPlanes::YZ: aParam = "VISU.Plot3D.YZ"; break;
-           case CutPlanes::ZX: aParam = "VISU.Plot3D.ZX"; break;
-           }
-           theStr<<thePrefix<<aName<<".SetOrientation("<<aParam<<","<<aServant->GetRotateX()<<","<<aServant->GetRotateY()<<")"<<endl;
-
-           theStr<<thePrefix<<aName<<".SetPlanePosition("<<aServant->GetPlanePosition()<<","<<aServant->IsPositionRelative()<<")"<<endl;
-           theStr<<thePrefix<<aName<<".SetScaleFactor("<<aServant->GetScaleFactor()<<")"<<endl;
-            theStr<<thePrefix<<aName<<".SetContourPrs("<<aServant->GetIsContourPrs()<<")"<<endl;
-            theStr<<thePrefix<<aName<<".SetNbOfContours("<<aServant->GetNbOfContours()<<")"<<endl;
+           TCreateFromResult aPrsFactory(theSObject, aServant, aName, "Plot3DOnField", theArgumentName);
+            thePrefix = Plot3DToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
             theStr<<thePrefix<<"pass"<<endl<<endl;
           }
           return;
+        case VISU::TGAUSSPOINTS:
+          if(GaussPoints_i* aServant = dynamic_cast<GaussPoints_i*>(GetServant(anObj).in())){
+           TCreateFromResult aPrsFactory(theSObject, aServant, aName, "GaussPointsOnField", theArgumentName);
+           thePrefix = GaussPointsToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
+           theStr<<thePrefix<<"pass"<<endl<<endl;
+          }
+          return;
         case VISU::TCURVE:
           if(Curve_i* aServant = dynamic_cast<Curve_i*>(GetServant(anObj).in()))
           {
-           theStr << thePrefix << "aName2ObjectMap['" << aName << "'] = visu.CreateCurve(" <<
+           bool withZ = aServant->GetZRow()>0;
+             
+           theStr << thePrefix << "aName2ObjectMap['" << aName << "'] = visu.CreateCurve";
+           if( withZ )
+             theStr << "WithZ";
+           theStr << "(" <<
               theArgumentName<< // table
-                ","<<aServant->GetHRow()<< // H row
-                  ","<<aServant->GetVRow()<< // V row
-                    ",'"<<aServant->GetTitle()<<"'"; // title
+                ", "<<aServant->GetHRow()<< // H row
+                  ", "<<aServant->GetVRow(); // V row
+           if( withZ )
+             theStr << ", " << aServant->GetZRow(); // Z row
+
+           theStr << ", '"<<aServant->GetTitle()<<"'"; // title
            SALOMEDS::Color aColor = aServant->GetColor();
            theStr << ",SALOMEDS.Color("<<
-             aColor.R<<","<<aColor.G<<","<<aColor.B<<")"; // color
+             aColor.R<<", "<<aColor.G<<", "<<aColor.B<<")"; // color
 
            std::string aParam;
            switch(aServant->GetMarker()){
@@ -882,7 +1325,7 @@ namespace VISU{
            case Curve::CROSS:     aParam = "VISU.Curve.CROSS";     break;
            case Curve::XCROSS:    aParam = "VISU.Curve.XCROSS";    break;
            }
-           theStr<<","<<aParam; // marker
+           theStr<<", "<<aParam; // marker
 
            switch(aServant->GetLine()){
            case Curve::VOIDLINE:       aParam = "VISU.Curve.VOIDLINE";       break;
@@ -892,19 +1335,18 @@ namespace VISU{
            case Curve::DASHDOTLINE:    aParam = "VISU.Curve.DASHDOTLINE";    break;
            case Curve::DASHDOTDOTLINE: aParam = "VISU.Curve.DASHDOTDOTLINE"; break;
            }
-           theStr<<","<<aParam<<","<<aServant->GetLineWidth()<<")"<<endl; // line type,width
+           theStr<<", "<<aParam<<", "<<aServant->GetLineWidth()<<")"<<endl; // line type,width
           }
          return;
         case VISU::TTABLE:
-          if(Table_i* aServant = dynamic_cast<Table_i*>(GetServant(anObj).in())){
-           SALOMEDS::SObject_var aSObject = aServant->GetSObject();
+          if(dynamic_cast<Table_i*>(GetServant(anObj).in())){
            SALOMEDS::GenericAttribute_var anAttr;
-           if(theSObject->FindAttribute(anAttr,"AttributeComment")){
+           if(theSObject->FindAttribute(anAttr,"AttributeString")){
              using namespace SALOMEDS;
-             AttributeComment_var aComment = AttributeComment::_narrow(anAttr);
+             AttributeString_var aComment = AttributeString::_narrow(anAttr);
              CORBA::String_var aValue = aComment->Value();
              Storable::TRestoringMap aMap;
-             Storable::StrToMap(aValue.in(),aMap);
+             Storable::StringToMap(aValue.in(),aMap);
              bool anIsExist;
              QString aSourceId = VISU::Storable::FindValue(aMap,"mySourceId",&anIsExist);
              if(anIsExist){
@@ -921,7 +1363,11 @@ namespace VISU{
 
                  theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
                  theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
-                 theStr<<endl;
+
+                 // Set name (as this object could be renamed by user)
+                 theStr<<thePrefix<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 2"<<endl;
+
+                 theStr<<thePrefix<<endl;
 
                  theArgumentName = aName;
                  DumpChildrenToPython(theStudy,
@@ -944,7 +1390,11 @@ namespace VISU{
 
                  theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
                  theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
-                 theStr<<endl;
+
+                 // Set name (as this object could be renamed by user)
+                 theStr<<thePrefix<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 3"<<endl;
+
+                 theStr<<thePrefix<<endl;
 
                  theArgumentName = aName;
                  DumpChildrenToPython(theStudy,
@@ -976,18 +1426,18 @@ namespace VISU{
           return;
        }
       }
-    }else{
+    } else { /*if(!CORBA::is_nil(anObj))*/
       SALOMEDS::GenericAttribute_var anAttr;
-      if(theSObject->FindAttribute(anAttr,"AttributeComment")){
-       SALOMEDS::AttributeComment_var aComment =
-         SALOMEDS::AttributeComment::_narrow(anAttr);
+      if (theSObject->FindAttribute(anAttr,"AttributeString")) {
+       SALOMEDS::AttributeString_var aComment =
+         SALOMEDS::AttributeString::_narrow(anAttr);
        CORBA::String_var aValue = aComment->Value();
        Storable::TRestoringMap aMap;
-       Storable::StrToMap(aValue.in(),aMap);
+       Storable::StringToMap(aValue.in(),aMap);
        bool anIsExist;
        QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
-       if(anIsExist){
-         if(strcmp(aTypeName.latin1(),"ImportTables") == 0){
+       if (anIsExist) {
+         if (strcmp(aTypeName.latin1(),"ImportTables") == 0) {
            QString aFileName = VISU::Storable::FindValue(aMap,"myFileName",&anIsExist);
            if(anIsExist){
              std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap);
@@ -1009,7 +1459,7 @@ namespace VISU{
              theStr<<thePrefix<<"pass"<<endl<<endl;
              return;
            }
-         }else if(strcmp(aTypeName.latin1(),"VIEW3D") == 0){
+         } else if (strcmp(aTypeName.latin1(),"VIEW3D") == 0) {
            std::string aName = GetName(theSObject);
            theStr<<thePrefix<<aName<<" = aBuilder.NewObject(aSComponent)"<<endl;
 
@@ -1019,14 +1469,45 @@ namespace VISU{
            theStr<<thePrefix<<"anAttr = aBuilder.FindOrCreateAttribute("<<aName<<",'AttributeName')"<<endl;
            theStr<<thePrefix<<"anAttr.SetValue('"<<aName<<"')"<<endl;
 
-           theStr<<thePrefix<<"anAttr = aBuilder.FindOrCreateAttribute("<<aName<<",'AttributeComment')"<<endl;
+           theStr<<thePrefix<<"anAttr = aBuilder.FindOrCreateAttribute("<<aName<<",'AttributeString')"<<endl;
            theStr<<thePrefix<<"anAttr.SetValue('"<<aValue.in()<<"')"<<endl;
 
            theStr<<thePrefix<<"pass"<<endl<<endl;
            return;
+         } else if (aTypeName == "ENTITY" || aTypeName == "FAMILY" || aTypeName == "GROUP") {
+           // Set name (as this object could be renamed by user)
+           string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
+           string aSubMeshName = VISU::Storable::FindValue(aMap,"myName").latin1();
+           string anEntityTypeKey = "myEntityId";
+           if (aTypeName == "ENTITY") anEntityTypeKey = "myId";
+           int anEntity = VISU::Storable::FindValue(aMap,anEntityTypeKey,"0").toInt();
+           std::string anEntityType;
+           switch ((TEntity)anEntity) {
+           case NODE_ENTITY: anEntityType = "VISU.NODE"; break;
+           case EDGE_ENTITY: anEntityType = "VISU.EDGE"; break;
+           case FACE_ENTITY: anEntityType = "VISU.FACE"; break;
+           case CELL_ENTITY: anEntityType = "VISU.CELL"; break;
+           }
+
+           if (aTypeName == "ENTITY" ) {
+             theStr<<thePrefix<<"aVisu.RenameEntityInStudy("<<theArgumentName<<", '"<<aMeshName
+                   <<"', "<<anEntityType<<", '"<<aNameInStudy.in()<<"')"<<endl;
+           }
+           else if (aTypeName == "FAMILY") {
+             if (aSubMeshName != aNameInStudy.in()) {
+               theStr<<thePrefix<<"aVisu.RenameFamilyInStudy("<<theArgumentName<<", '"<<aMeshName
+                     <<"', "<<anEntityType<<", '"<<aSubMeshName<<"', '"<<aNameInStudy.in()<<"')"<<endl;
+             }
+           }
+           else { // "GROUP"
+             if (aSubMeshName != aNameInStudy.in()) {
+               theStr<<thePrefix<<"aVisu.RenameGroupInStudy("<<theArgumentName<<", '"<<aMeshName
+                     <<"', '"<<aSubMeshName<<"', '"<<aNameInStudy.in()<<"')"<<endl;
+             }
+           }
          }
        }
-      }else{
+      } else {
        DumpTableAttrToPython(theStudy,
                              theIsPublished,
                              theIsValidScript,
@@ -1051,7 +1532,7 @@ namespace VISU{
   }
 
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
   void
   DumpCurveToPython(SALOMEDS::Study_ptr theStudy,
                    CORBA::Boolean theIsPublished,
@@ -1086,7 +1567,7 @@ namespace VISU{
   }
 
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
   void
   DumpContainersToPython(SALOMEDS::Study_ptr theStudy,
                         CORBA::Boolean theIsPublished,
@@ -1110,13 +1591,17 @@ namespace VISU{
        continue;
 
       if(aBase->GetType() == VISU::TCONTAINER){
-       theStr<<endl;
+       theStr<<thePrefix<<endl;
        std::string aName = GenerateName(aSObject,theName2EntryMap,theEntry2NameMap);
        theStr<<thePrefix<<aName<<" = aVisu.CreateContainer()"<<endl;
        theStr<<thePrefix<<"if "<<aName<<":"<<endl;
        std::string aPrefix = thePrefix + PREFIX;
        theArgumentName = aName;
 
+       // Set name (as this object could be renamed by user)
+       CORBA::String_var aNameInStudy = aSObject->GetName();
+       theStr<<aPrefix<<"visu.SetName("<<aName<<", '"<<aNameInStudy.in()<<"')"<<endl;
+
        SALOMEDS::ChildIterator_var aCurveIter = theStudy->NewChildIterator(aSObject);
        for(aCurveIter->InitEx(false); aCurveIter->More(); aCurveIter->Next()){
          SALOMEDS::SObject_var aRefSObj = aCurveIter->Value();
@@ -1129,13 +1614,256 @@ namespace VISU{
   }
 
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
+  void
+  DumpPrs3dCacheToPython(SALOMEDS::Study_ptr theStudy,
+                        CORBA::Boolean theIsPublished,
+                        CORBA::Boolean& theIsValidScript,
+                        SALOMEDS::SObject_ptr theSObject,
+                        std::ostream& theStr,
+                        TName2EntryMap& theName2EntryMap,
+                        TEntry2NameMap& theEntry2NameMap,
+                        std::string theArgumentName,
+                        std::string thePrefix)
+  {
+
+    SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(theSObject);
+    for(anIter->InitEx(false); anIter->More(); anIter->Next()){
+      SALOMEDS::SObject_var aSObject = anIter->Value();
+      CORBA::Object_var anObj = SObjectToObject(aSObject);
+      if(CORBA::is_nil(anObj))
+       continue;
+
+      VISU::Base_var aBase = VISU::Base::_narrow(anObj);
+      if(CORBA::is_nil(aBase))
+       continue;
+
+      if(aBase->GetType() == VISU::TCOLOREDPRS3DCACHE){
+       ColoredPrs3dCache_i* aCache = dynamic_cast<ColoredPrs3dCache_i*>(GetServant(aBase).in());
+       theStr<<thePrefix<<"aCache = aVisu.GetColoredPrs3dCache(aVisu.GetCurrentStudy())"<<endl;
+       theStr<<thePrefix<<"if aCache != None:"<<endl;
+       {
+         std::string aPrefix = thePrefix + PREFIX;
+         std::string anArgument;
+         VISU::ColoredPrs3dCache::MemoryMode aMode = aCache->GetMemoryMode();
+         switch(aMode){
+         case VISU::ColoredPrs3dCache::MINIMAL : anArgument = "VISU.ColoredPrs3dCache.MINIMAL"; break;
+         case VISU::ColoredPrs3dCache::LIMITED : anArgument = "VISU.ColoredPrs3dCache.LIMITED"; break;
+         }
+         theStr<<aPrefix<<"aCache.SetMemoryMode("<<anArgument<<")"<<endl;
+
+         if(aMode == VISU::ColoredPrs3dCache::LIMITED)
+           theStr<<aPrefix<<"aCache.SetLimitedMemory("<<aCache->GetLimitedMemory()<<") # (Mb)"<<endl;
+
+         SALOMEDS::ChildIterator_var aChildIter = theStudy->NewChildIterator(aSObject);
+         for(aChildIter->InitEx(false); aChildIter->More(); aChildIter->Next()){
+           SALOMEDS::SObject_var aSObject = aChildIter->Value();
+           CORBA::Object_var anObject = SObjectToObject(aSObject);
+           if (CORBA::is_nil(anObject))
+             continue;
+           
+           ColoredPrs3dHolder_i* aServant = dynamic_cast<ColoredPrs3dHolder_i*>(GetServant(anObject).in());
+           if(!aServant)
+             continue;
+         
+           ColoredPrs3d_i* aDevice = aServant->GetPrs3dDevice();
+           if(!aDevice)
+             continue;
+           
+           Result_i* aResult = aDevice->GetCResult();
+           std::string aResultEntry = aResult->GetEntry();
+           std::string aResultName = theEntry2NameMap[aResultEntry];
+           
+           ColoredPrs3dHolder::BasicInput_var anInput = aServant->GetBasicInput();
+           std::string anEntity;
+           switch(anInput->myEntity){
+           case VISU::NODE : anEntity = "VISU.NODE"; break;
+           case VISU::EDGE : anEntity = "VISU.EDGE"; break;
+           case VISU::FACE : anEntity = "VISU.FACE"; break;
+           case VISU::CELL : anEntity = "VISU.CELL"; break;
+           }
+           
+           
+           theStr<<aPrefix<<"anInput = VISU.ColoredPrs3dHolder.BasicInput("<<
+             aResultName<<", '"<<
+             anInput->myMeshName<<"', "<<
+             anEntity<<", '"<<
+             anInput->myFieldName<<"', "<<
+             anInput->myTimeStampNumber<<")"<<
+             endl;
+         
+           std::string aComment = aDevice->GetComment();
+           theStr<<aPrefix<<"aHolder = aCache.CreateHolder(VISU.T"<<aComment<<", anInput)"<<endl;
+           theStr<<aPrefix<<"if aHolder != None:"<<endl;
+           {
+             std::string aPrefix2 = aPrefix + PREFIX;
+             CORBA::String_var aNameInStudy = aSObject->GetName();
+             theStr<<aPrefix2<<"visu.SetName(aHolder, '"<<aNameInStudy.in()<<"')"<<endl;
+             theStr<<aPrefix2<<"aDevice = aHolder.GetDevice()"<<endl;
+             theStr<<aPrefix2<<"if aDevice != None:"<<endl;
+             {
+               std::string aPrefix3 = aPrefix2 + PREFIX;
+               TColoredPrs3dFactory aPrsFactory;
+               switch(aDevice->GetType()){
+               case VISU::TSCALARMAP:
+                 if(ScalarMap_i* aServant = dynamic_cast<ScalarMap_i*>(aDevice)){
+                   ScalarMapToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
+                   break;
+                 }
+               case VISU::TDEFORMEDSHAPE:
+                 if(DeformedShape_i* aServant = dynamic_cast<DeformedShape_i*>(aDevice)){
+                   DeformedShapeToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
+                   break;
+                 }
+               case VISU::TSTREAMLINES:
+                 if(StreamLines_i* aServant = dynamic_cast<StreamLines_i*>(aDevice)){
+                   StreamLinesToPython(aSObject, aServant, theStr, theEntry2NameMap, "aDevice", aPrsFactory, aPrefix3);
+                   break;
+                 }
+               case VISU::TSCALARMAPONDEFORMEDSHAPE:
+                 if(ScalarMapOnDeformedShape_i* aServant = dynamic_cast<ScalarMapOnDeformedShape_i*>(aDevice)){
+                   ScalarMapOnDeformedShapeToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
+                   break;
+                 }
+               case VISU::TVECTORS:
+                 if(Vectors_i* aServant = dynamic_cast<Vectors_i*>(aDevice)){
+                   VectorsToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
+                   break;
+                 }
+               case VISU::TISOSURFACES:
+                 if(IsoSurfaces_i* aServant = dynamic_cast<IsoSurfaces_i*>(aDevice)){
+                   IsoSurfacesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
+                   break;
+                 }
+               case VISU::TCUTPLANES:
+                 if(CutPlanes_i* aServant = dynamic_cast<CutPlanes_i*>(aDevice)){
+                   CutPlanesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
+                   break;
+                 }
+               case VISU::TCUTLINES:
+                 if(CutLines_i* aServant = dynamic_cast<CutLines_i*>(aDevice)){
+                   CutLinesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
+                   break;
+                 }
+               case VISU::TPLOT3D:
+                 if(Plot3D_i* aServant = dynamic_cast<Plot3D_i*>(aDevice)){
+                   Plot3DToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
+                   break;
+                 }
+               case VISU::TGAUSSPOINTS:
+                 if(GaussPoints_i* aServant = dynamic_cast<GaussPoints_i*>(aDevice)){
+                   GaussPointsToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
+                   break;
+                 }
+               }
+               theStr<<aPrefix3<<"pass"<<endl;
+             }
+             theStr<<aPrefix2<<"pass"<<endl<<endl;
+           }
+         }
+         theStr<<aPrefix<<"pass"<<endl;
+       }
+      }
+    }
+  }
+
+    
+  //---------------------------------------------------------------------------
+  void
+  DumpAnimationsToPython(SALOMEDS::Study_ptr theStudy,
+                        CORBA::Boolean theIsPublished,
+                        CORBA::Boolean& theIsValidScript,
+                        SALOMEDS::SObject_ptr theSObject,
+                        std::ostream& theStr,
+                        std::string thePrefix)
+  {
+
+    if(!theIsPublished) return;
+
+    SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
+    for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
+      SALOMEDS::SObject_var aSObject = aChildItet->Value();
+          
+      SALOMEDS::GenericAttribute_var anAttr;
+      if (!aSObject->FindAttribute(anAttr, "AttributeString")) continue;
+      
+      SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
+      QString value (aStringAttr->Value());
+      if(value.isEmpty()) continue;
+
+      VISU::Storable::TRestoringMap aMap;
+      VISU::Storable::StringToMap(value, aMap);
+      bool isExist;
+      
+      QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&isExist);
+      if(!isExist || aTypeName != "ANIMATION") continue;
+
+      //ANIMATION
+      theStr<<thePrefix<<endl;
+      QString animName = aSObject->GetName();
+      theStr<<thePrefix<<"#Animation: "<<animName<<endl;
+      theStr<<thePrefix<<endl;
+      theStr<<thePrefix<<"animSO = aBuilder.NewObject(aSComponent)"<<endl;
+      theStr<<thePrefix<<"aBuilder.SetName(animSO, '"<<animName<<"')"<< endl;
+      theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(animSO, 'AttributeString')"<< endl;
+      theStr<<thePrefix<<"strAttr.SetValue('"<<value<<"')"<< endl;
+
+
+    
+      SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(aSObject);
+      for (anIter->Init(); anIter->More(); anIter->Next()) {
+       SALOMEDS::SObject_var anObj = anIter->Value();
+
+       //FIELD
+       theStr<<thePrefix<<"fieldSO = aBuilder.NewObject(animSO)"<<endl;
+       if (anObj->FindAttribute(anAttr, "AttributeString")) {
+         aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
+         theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(fieldSO, 'AttributeString')"<< endl;
+         theStr<<thePrefix<<"strAttr.SetValue('"<<aStringAttr->Value()<<"')"<< endl;
+       }
+       
+       SALOMEDS::SObject_var refObj;
+       if(anObj->ReferencedObject(refObj)) {
+         SALOMEDS::SObject_var father = refObj->GetFather();
+         value = refObj->GetName();
+         QString path(theStudy->GetObjectPath(father));
+         //The following code requierd as a field name can contain '/' character
+         theStr<<thePrefix<<"aBuilder.Addreference(fieldSO,getSObjectByFatherPathAndName(theStudy, '"<<path<<"', '"<<value<<"'))"<<endl;
+       }
+       value = anObj->GetName();
+       if(!value.isEmpty()) theStr<<thePrefix<<"aBuilder.SetName(fieldSO, '"<<value<<"')"<< endl;
+
+       //SCALARMAP,...
+       SALOMEDS::ChildIterator_var aSubIter = theStudy->NewChildIterator(anObj);
+       for (aSubIter->Init(); aSubIter->More(); aSubIter->Next()) {
+         SALOMEDS::SObject_var aSubObj = aSubIter->Value();
+         
+         theStr<<thePrefix<<"subSO = aBuilder.NewObject(fieldSO)"<<endl;
+         value = aSubObj->GetName();
+         if(!value.isEmpty()) theStr<<thePrefix<<"aBuilder.SetName(subSO, '"<<value<<"')"<< endl;
+         if (aSubObj->FindAttribute(anAttr, "AttributeString")) {
+           aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
+           theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(subSO, 'AttributeString')"<< endl;
+           theStr<<thePrefix<<"strAttr.SetValue('"<<aStringAttr->Value()<<"')"<< endl;
+         }
+       }
+
+      }
+      
+    }
+
+    theStr<<thePrefix<<endl;
+  }
+
+  //---------------------------------------------------------------------------
   Engines::TMPFile*
   VISU_Gen_i::
   DumpPython(CORBA::Object_ptr theStudy,
             CORBA::Boolean theIsPublished,
             CORBA::Boolean& theIsValidScript)
   {
+    theIsValidScript = false;
+
     SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
     if(CORBA::is_nil(aStudy))
       return new Engines::TMPFile(0);
@@ -1150,7 +1878,7 @@ namespace VISU{
 #endif
 
     std::string aPrefix(PREFIX);
-    aStr<<"### This file is generated by SALOME automatically by dump python funcitonality"
+    aStr<<"### This file is generated by SALOME automatically by dump python functionality"
       " of VISU component"<<endl<<endl;
     aStr<<"def RebuildData(theStudy):"<<endl;
     aStr<<aPrefix<<"from batchmode_salome import orb, naming_service, lcc, myStudyManager"<<endl;
@@ -1167,11 +1895,78 @@ namespace VISU{
     aStr<<endl;
 
     SALOMEDS::SComponent_var aComponent = FindOrCreateVisuComponent(aStudy);
-    VISU::DumpChildrenToPython(aStudy,theIsPublished,theIsValidScript,aComponent.in(),aStr,aName2EntryMap,aEntry2NameMap,"",aPrefix);
-    VISU::DumpContainersToPython(aStudy,theIsPublished,theIsValidScript,aComponent.in(),aStr,aName2EntryMap,aEntry2NameMap,"",aPrefix);
+    VISU::DumpChildrenToPython(aStudy,
+                              theIsPublished,
+                              theIsValidScript,
+                              aComponent.in(),
+                              aStr,
+                              aName2EntryMap,
+                              aEntry2NameMap,
+                              "",
+                              aPrefix);
+
+    VISU::DumpContainersToPython(aStudy,
+                                theIsPublished,
+                                theIsValidScript,
+                                aComponent.in(),
+                                aStr,
+                                aName2EntryMap,
+                                aEntry2NameMap,
+                                "",
+                                aPrefix);
+
+    VISU::DumpPrs3dCacheToPython(aStudy,
+                                theIsPublished,
+                                theIsValidScript,
+                                aComponent.in(),
+                                aStr,
+                                aName2EntryMap,
+                                aEntry2NameMap,
+                                "",
+                                aPrefix);
+
+    VISU::DumpAnimationsToPython(aStudy,
+                                theIsPublished,
+                                theIsValidScript,
+                                aComponent.in(),
+                                aStr,
+                                aPrefix);
+
+    //Output the script that sets up the visul parameters.
+    if(theIsPublished) {
+      char* script = aStudy->GetDefaultScript("Post-Pro", aPrefix.c_str());
+      if(script && strlen(script) > 0) {
+       aStr << script;
+       CORBA::string_free(script);
+      }
+    }
 
     aStr<<aPrefix<<"pass"<<endl;
 
+    if(theIsPublished) { //SRN: define function for Animation
+
+      //Define a function that find a SObject by its father's path and its name
+      aStr<<endl;
+      aStr<<endl;
+
+      aStr<<"def getSObjectByFatherPathAndName(theStudy, thePath, theName):"<<endl;
+      aStr<<aPrefix<<"father = theStudy.FindObjectByPath(thePath)"<<endl;
+      aStr<<aPrefix<<"itr = theStudy.NewChildIterator(father)"<<endl;
+      aStr<<aPrefix<<"while itr.More():"<<endl;
+      aStr<<aPrefix<<aPrefix<<"so = itr.Value()"<<endl;
+      aStr<<aPrefix<<aPrefix<<"if so.GetName()==theName: return so"<<endl;
+      aStr<<aPrefix<<aPrefix<<"itr.Next()"<<endl;
+      aStr<<aPrefix<<aPrefix<<"pass"<<endl;
+      aStr<<aPrefix<<"return None"<<endl;
+
+      aStr<<endl;
+    }
+
+    // theIsValidScript currently is not used by internal dump methods (DumpChildrenToPython(), etc.)
+    // If the situation changes, then the following line should be removed, and theIsValidScript
+    // should be set properly by those internal methods
+    theIsValidScript = true;
+
 #ifndef COUT
     std::string aResult = aStr.str();
     //ofstream anFStream("/tmp/dump.py");