]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #3223: Improve Python dump readability
authorvsv <vsv@opencascade.com>
Fri, 17 Apr 2020 19:00:30 +0000 (22:00 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Mon, 6 Jul 2020 06:53:15 +0000 (09:53 +0300)
* Add empty lines between features
* Add comments related to the type of features
* Improve dumping of lists
* Fix the wrong script generation if a group contains filters.

src/ModelAPI/Test/Test2491.py
src/ModelHighAPI/ModelHighAPI.i
src/ModelHighAPI/ModelHighAPI_Dumper.cpp
src/ModelHighAPI/ModelHighAPI_Dumper.h
src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp
src/ModelHighAPI/ModelHighAPI_Tools.cpp
src/PythonAPI/model/dump/DumpAssistant.py
src/SketchAPI/SketchAPI_Constraint.cpp
src/SketchAPI/SketchAPI_ConstraintAngle.cpp

index 80e23e406671da66ba31236338dc79c40582a32d..57538539ddf9727cd278c864f661fed8e88fd667 100644 (file)
@@ -31,68 +31,58 @@ SketchLine_2 = Sketch_1.addLine(20, 2.492755359431925e-15, 20, -31)
 SketchLine_3 = Sketch_1.addLine(-25.74772708486752, -20, -17.21320343559642, -20)
 SketchLine_4 = Sketch_1.addLine(-13.67766952966368, -21.46446609406726, 2.928932188134523, -38.07106781186547)
 SketchArc_1 = Sketch_1.addArc(-17.21320343559642, -25, -13.67766952966368, -21.46446609406726, -17.21320343559642, -20, False)
-SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_4.startPoint())
-SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_3.endPoint())
-SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_4.result())
-SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_3.result())
-SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result())
-SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_4.startPoint())
+Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_3.endPoint())
+Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_4.result())
+Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_3.result())
+Sketch_1.setHorizontal(SketchLine_3.result())
+Sketch_1.setVertical(SketchLine_2.result())
 SketchArc_2 = Sketch_1.addArc(0, 6.520200294596256e-23, -4.760492650097915, 19.42518236023452, 20, 2.492755359431925e-15, True)
-SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchArc_2.startPoint())
+Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchArc_2.startPoint())
 SketchArc_3 = Sketch_1.addArc(-12, -5, -29.79117622747561, -17.94117647058824, -17.23654191510763, 16.36770059625792, True)
-SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_1.startPoint())
-SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_5")
-SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_3.results()[1], SketchLine_1.result())
-SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_2.startPoint())
-SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_6")
+Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_1.startPoint())
+Sketch_1.setTangent(SketchArc_3.results()[1], SketchLine_1.result())
+Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_2.startPoint())
 SketchArc_4 = Sketch_1.addArc(-25.74772708486752, -15, -29.79117622747561, -17.94117647058824, -25.74772708486752, -20, False)
-SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchArc_4.startPoint(), SketchArc_3.startPoint())
-SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7")
-SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_4.endPoint(), SketchLine_3.startPoint())
-SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_8")
-SketchConstraintTangent_4 = Sketch_1.setTangent(SketchArc_4.results()[1], SketchLine_3.result())
-SketchConstraintTangent_5 = Sketch_1.setTangent(SketchArc_4.results()[1], SketchArc_3.results()[1])
+Sketch_1.setCoincident(SketchArc_4.startPoint(), SketchArc_3.startPoint())
+Sketch_1.setCoincident(SketchArc_4.endPoint(), SketchLine_3.startPoint())
+Sketch_1.setTangent(SketchArc_4.results()[1], SketchLine_3.result())
+Sketch_1.setTangent(SketchArc_4.results()[1], SketchArc_3.results()[1])
 SketchArc_5 = Sketch_1.addArc(10, -31, 20, -31, 2.928932188134523, -38.07106781186547, True)
-SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_5.startPoint())
-SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_9")
-SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchArc_5.endPoint(), SketchLine_4.endPoint())
-SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_10")
-SketchConstraintTangent_6 = Sketch_1.setTangent(SketchArc_5.results()[1], SketchLine_4.result())
-SketchConstraintTangent_7 = Sketch_1.setTangent(SketchLine_2.result(), SketchArc_5.results()[1])
-SketchConstraintTangent_8 = Sketch_1.setTangent(SketchLine_1.result(), SketchArc_2.results()[1])
-SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), 31)
-SketchConstraintTangent_9 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_2.result())
-SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_3.result(), SketchLine_4.result(), 135)
-SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 5)
-SketchConstraintEqual_1 = Sketch_1.setEqual(SketchArc_4.results()[1], SketchArc_1.results()[1])
-SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_5.results()[1], 10)
-SketchConstraintRadius_3 = Sketch_1.setRadius(SketchArc_2.results()[1], 20)
-SketchConstraintRadius_4 = Sketch_1.setRadius(SketchArc_3.results()[1], 22)
+Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_5.startPoint())
+Sketch_1.setCoincident(SketchArc_5.endPoint(), SketchLine_4.endPoint())
+Sketch_1.setTangent(SketchArc_5.results()[1], SketchLine_4.result())
+Sketch_1.setTangent(SketchLine_2.result(), SketchArc_5.results()[1])
+Sketch_1.setTangent(SketchLine_1.result(), SketchArc_2.results()[1])
+Sketch_1.setLength(SketchLine_2.result(), 31)
+Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_2.result())
+Sketch_1.setAngle(SketchLine_3.result(), SketchLine_4.result(), 135)
+Sketch_1.setRadius(SketchArc_1.results()[1], 5)
+Sketch_1.setEqual(SketchArc_4.results()[1], SketchArc_1.results()[1])
+Sketch_1.setRadius(SketchArc_5.results()[1], 10)
+Sketch_1.setRadius(SketchArc_2.results()[1], 20)
+Sketch_1.setRadius(SketchArc_3.results()[1], 22)
 SketchCircle_1 = Sketch_1.addCircle(-22, -5, 7.5)
 SketchLine_5 = Sketch_1.addLine(-22, -5, -12, -5)
 SketchLine_5.setAuxiliary(True)
-SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_5.startPoint())
-SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_11")
-SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_3.center(), SketchLine_5.endPoint())
-SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_12")
-SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_5.result())
-SketchConstraintRadius_5 = Sketch_1.setRadius(SketchCircle_1.results()[1], 7.5)
+Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_5.startPoint())
+Sketch_1.setCoincident(SketchArc_3.center(), SketchLine_5.endPoint())
+Sketch_1.setHorizontal(SketchLine_5.result())
+Sketch_1.setRadius(SketchCircle_1.results()[1], 7.5)
 SketchCircle_2 = Sketch_1.addCircle(0, 6.520200294596256e-23, 10)
-SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchArc_2.center(), SketchCircle_2.center())
-SketchConstraintCoincidence_12.setName("SketchConstraintCoincidence_13")
-SketchConstraintRadius_6 = Sketch_1.setRadius(SketchCircle_2.results()[1], 10)
-SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchCircle_2.center(), SketchArc_3.center(), 5)
+Sketch_1.setCoincident(SketchArc_2.center(), SketchCircle_2.center())
+Sketch_1.setRadius(SketchCircle_2.results()[1], 10)
+Sketch_1.setVerticalDistance(SketchCircle_2.center(), SketchArc_3.center(), 5)
 SketchCircle_3 = Sketch_1.addCircle(7, -25, 7.5)
-SketchConstraintRadius_7 = Sketch_1.setRadius(SketchCircle_3.results()[1], 7.5)
-SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchArc_2.center(), SketchCircle_3.center(), 7)
-SketchConstraintDistance_1 = Sketch_1.setDistance(SketchCircle_2.center(), SketchLine_3.result(), 20, True)
-SketchConstraintDistanceVertical_2 = Sketch_1.setVerticalDistance(SketchArc_2.center(), SketchCircle_3.center(), 25)
-SketchConstraintDistanceHorizontal_2 = Sketch_1.setHorizontalDistance(SketchLine_5.endPoint(), SketchArc_2.center(), 12)
-SketchConstraintDistanceHorizontal_3 = Sketch_1.setHorizontalDistance(SketchCircle_1.center(), SketchArc_2.center(), 22)
+Sketch_1.setRadius(SketchCircle_3.results()[1], 7.5)
+Sketch_1.setHorizontalDistance(SketchArc_2.center(), SketchCircle_3.center(), 7)
+Sketch_1.setDistance(SketchCircle_2.center(), SketchLine_3.result(), 20, True)
+Sketch_1.setVerticalDistance(SketchArc_2.center(), SketchCircle_3.center(), 25)
+Sketch_1.setHorizontalDistance(SketchLine_5.endPoint(), SketchArc_2.center(), 12)
+Sketch_1.setHorizontalDistance(SketchCircle_1.center(), SketchArc_2.center(), 22)
 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
 SketchPoint_1 = SketchProjection_1.createdFeature()
-SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchCircle_2.center(), SketchAPI_Point(SketchPoint_1).coordinates())
-SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_14")
+Sketch_1.setCoincident(SketchCircle_2.center(), SketchAPI_Point(SketchPoint_1).coordinates())
 model.do()
 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_3_2f-SketchArc_4_2f-SketchLine_3f-SketchArc_1_2r-SketchLine_4f-SketchArc_5_2f-SketchLine_2r-SketchArc_2_2f-SketchLine_1r-SketchCircle_1_2r-SketchCircle_2_2r-SketchCircle_3_2r")], model.selection(), 6.5, 0)
 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2"))
@@ -100,18 +90,14 @@ SketchLine_6 = Sketch_2.addLine(14.45330132699559, 5.092287733454298, -12.158140
 SketchLine_7 = Sketch_2.addLine(-12.15814035598059, 5.092287733454298, -12.15814035598059, 23.78152371848275)
 SketchLine_8 = Sketch_2.addLine(-12.15814035598059, 23.78152371848275, 14.45330132699559, 23.78152371848275)
 SketchLine_9 = Sketch_2.addLine(14.45330132699559, 23.78152371848275, 14.45330132699559, 5.092287733454298)
-SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_6.startPoint())
-SketchConstraintCoincidence_14.setName("SketchConstraintCoincidence_15")
-SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
-SketchConstraintCoincidence_15.setName("SketchConstraintCoincidence_16")
-SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
-SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_17")
-SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
-SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_18")
-SketchConstraintHorizontal_3 = Sketch_2.setHorizontal(SketchLine_6.result())
-SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_7.result())
-SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_8.result())
-SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_9.result())
+Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_6.startPoint())
+Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
+Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
+Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
+Sketch_2.setHorizontal(SketchLine_6.result())
+Sketch_2.setVertical(SketchLine_7.result())
+Sketch_2.setHorizontal(SketchLine_8.result())
+Sketch_2.setVertical(SketchLine_9.result())
 model.do()
 ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_9r-SketchLine_8r-SketchLine_7r-SketchLine_6r")], model.selection(), 0, 100, [model.selection("SOLID", "Extrusion_1_1")])
 model.do()
index 6c7101b3985bd6ff39e729f8dc30cea5b99329ea..778261db1f80229da20d80fcc35681e198b9d9ba 100644 (file)
@@ -54,6 +54,9 @@
 // directors
 %feature("director") ModelHighAPI_Dumper;
 
+// renamed methods
+%rename(__print__) ModelHighAPI_Dumper::operator<<;
+
 // shared pointers
 %shared_ptr(ModelHighAPI_Interface)
 %shared_ptr(ModelHighAPI_Folder)
index 15d10c6aa7c01e9678042c848c0c4a20021663bc..636726edabedf10991cdd2bfd863b1e51553a6c0 100644 (file)
@@ -569,12 +569,16 @@ static int toInt(const std::string& theString)
 
 const std::string& ModelHighAPI_Dumper::name(const EntityPtr& theEntity,
                                              bool theSaveNotDumped,
-                                             bool theUseEntityName)
-{
-  EntityNameMap::const_iterator aFound = myNames.find(theEntity);
-  if (aFound != myNames.end())
+                                             bool theUseEntityName,
+                                             bool theSetIsDumped)
+{
+  EntityNameMap::iterator aFound = myNames.find(theEntity);
+  if (aFound != myNames.end()) {
+    // Set dumped flag for postponed constraints which are without names
+    if (!aFound->second.myIsDumped)
+      aFound->second.myIsDumped = theSetIsDumped;
     return aFound->second.myCurrentName;
-
+  }
   // entity is not found, store it
   std::string aName, aKind;
   bool isDefaultName = false;
@@ -650,6 +654,8 @@ const std::string& ModelHighAPI_Dumper::name(const EntityPtr& theEntity,
   if (aFeature)
     saveResultNames(aFeature);
 
+  myNames[theEntity].myIsDumped = theSetIsDumped;
+
   return myNames[theEntity].myCurrentName;
 }
 
@@ -771,7 +777,7 @@ bool ModelHighAPI_Dumper::process(const std::shared_ptr<ModelAPI_CompositeFeatur
     // dump features in the document
     bool aRes = process(aSubDoc);
     if (isDumpModelDo)
-      *this << "model.do()\n";
+      *this << "\nmodel.do()\n";
     *this << std::endl;
     return aRes;
   }
@@ -1053,6 +1059,16 @@ bool ModelHighAPI_Dumper::isDefaultTransparency(const ResultPtr& theResult) cons
   return fabs(anAttribute->value()) < 1.e-12;
 }
 
+bool ModelHighAPI_Dumper::dumpCommentBeforeFeature(const FeaturePtr& theFeature) const
+{
+  // currently, the comment should not be dumped only before the filters
+  FiltersFeaturePtr aFilters = std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(theFeature);
+  if (aFilters)
+    return false;
+  // all other features should be commented before the dump
+  return true;
+}
+
 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const char theChar)
 {
   *myDumpStorage << theChar;
@@ -1446,10 +1462,10 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
     const std::shared_ptr<ModelAPI_AttributeSelectionList>& theAttrSelList)
 {
   static const int aThreshold = 2;
-  static bool aDumpAsIs = false;
+  static int aNbSpaces = 0;
   // if number of elements in the list if greater than a threshold,
   // dump it in a separate line with specific name
-  if (aDumpAsIs || theAttrSelList->size() <= aThreshold) {
+  if (aNbSpaces > 0 || theAttrSelList->size() <= aThreshold) {
     *myDumpStorage << "[";
 
     GeomShapePtr aShape;
@@ -1472,6 +1488,11 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
 
       if(isAdded) {
         *myDumpStorage << ", ";
+        // print each attribute on separate line with the appropriate shift
+        if (aNbSpaces > 0) {
+          std::string aSpaces(aNbSpaces + 1, ' ');
+          *myDumpStorage << "\n" << aSpaces;
+        }
       } else {
         isAdded = true;
       }
@@ -1505,9 +1526,9 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
     }
     // reserve dumped buffer and store list "as is"
     myDumpStorage->reserveBuffer();
-    aDumpAsIs = true;
+    aNbSpaces = (int)aListName.size() + 3;
     *this << aListName << " = " << theAttrSelList << "\n";
-    aDumpAsIs = false;
+    aNbSpaces = 0;
     // append reserved data to the end of the current buffer
     myDumpStorage->restoreReservedBuffer();
     *myDumpStorage << aListName;
@@ -1532,6 +1553,11 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
   return *this;
 }
 
+void ModelHighAPI_Dumper::newline()
+{
+  *this << std::endl;
+}
+
 /// Dump std::endl
 ModelHighAPI_Dumper& operator<<(ModelHighAPI_Dumper& theDumper,
                                 std::basic_ostream<char>& (*theEndl)(std::basic_ostream<char>&))
@@ -1561,6 +1587,7 @@ ModelHighAPI_Dumper& operator<<(ModelHighAPI_Dumper& theDumper,
 
   // store all not-dumped entities first
   std::set<EntityPtr> aNotDumped = theDumper.myNotDumpedEntities;
+  theDumper.clearNotDumped();
   theDumper.myDumpStorage->reserveBuffer();
   std::set<EntityPtr>::const_iterator anIt = aNotDumped.begin();
   for (; anIt != aNotDumped.end(); ++anIt) {
index 46eee3ff829c1ce98c4038114b035b89c3480102..5a0461f052938887202f359916d124f9d0825af9 100644 (file)
@@ -183,7 +183,7 @@ public:
   /// \return name of the entity
   MODELHIGHAPI_EXPORT
   const std::string& name(const EntityPtr& theEntity, bool theSaveNotDumped = true,
-                          bool theUseEntityName = false);
+                          bool theUseEntityName = false, bool theSetIsDumped = false);
 
   /// Returns name of parent composite feature for specified entity
   MODELHIGHAPI_EXPORT
@@ -245,6 +245,9 @@ public:
   ModelHighAPI_Dumper& operator<<(ModelHighAPI_Dumper& theDumper,
                                 std::basic_ostream<char>& (*theEndl)(std::basic_ostream<char>&));
 
+  /// Print std::endl from Python
+  MODELHIGHAPI_EXPORT void newline();
+
   /// Dump GeomAPI_Pnt in the following form:
   /// "GeomAPI_Pnt(X, Y, Z)"
   MODELHIGHAPI_EXPORT
@@ -355,6 +358,10 @@ public:
   MODELHIGHAPI_EXPORT virtual void exportVariable(const std::string& /*theEntry*/,
                                                   const std::string& /*theVarName*/) const {}
 
+  /// Returns \c true if the special comment line to improve the readability
+  /// should be printed before the feature of the given kind.
+  MODELHIGHAPI_EXPORT bool dumpCommentBeforeFeature(const FeaturePtr& theFeature) const;
+
 protected:
   /// Dump "setName" command if last entity had user-defined name
   MODELHIGHAPI_EXPORT void dumpEntitySetName();
index 198a0906526dc27432a232a7c0d9b5a386d18476..bf7a6fa9e39aa8c179b2b169d409f5eb45f0ac3d 100644 (file)
@@ -287,8 +287,11 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) {
         if (isSketchFeatures) {
           // do not control construction features of an ellipse and other
           FeaturePtr aFeature = ModelAPI_Feature::feature(*aL);
-          if (aFeature->getKind() == "SketchConstraintCoincidenceInternal")
-            continue; // skip internal constraints
+          //if (aFeature->getKind() == "SketchConstraintCoincidenceInternal")
+          //  continue; // skip internal constraints
+          std::string aStr = aFeature->getKind().substr(0, 16);
+          if (aStr == "SketchConstraint")
+            continue; // no need to dump and check constraints
         }
         aResList.push_back((*aL)->data()->name());
       } else if (!isSketchFeatures) {
index 4b4b689e31711c5ab41d698d8a6deec1fb151f55..0b91369bf71167a38dfbe109721542d3f2aade6f 100644 (file)
@@ -431,9 +431,13 @@ std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc,
   for(; allIter != allObjects.end(); allIter++) {
     ObjectPtr anObject = *allIter;
     FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
-    if (aFeature && aFeature->getKind() == "SketchConstraintCoincidenceInternal")
-      continue; // no need to dump and check internal constraints
+    //if (aFeature && aFeature->getKind() == "SketchConstraintCoincidenceInternal")
 
+    if (aFeature) {
+      std::string aStr = aFeature->getKind().substr(0, 16);
+      if (aStr == "SketchConstraint")
+        continue; // no need to dump and check constraints
+    }
     if (theCompare) {
       std::map<std::string, ModelHighAPI_FeatureStore>::iterator
         anObjFind = aDocFind->second.find(anObject->data()->name());
index d41af2b70030588c43c3a67b9387bab98b4a6177..8d688054b9ebfe260b69b415708f2916e1069fbc 100644 (file)
@@ -58,20 +58,28 @@ class DumpAssistant(ModelHighAPI.ModelHighAPI_Dumper):
 
     ## Create wrapper for a given feature and dump it
     def dumpFeature(self, theFeature, theForce):
+        aDumper = None
         aFeatureKind = theFeature.getKind()
         if aFeatureKind in self.myFeatures:
             # Dump only feature created by user (in history).
             # Also dump Export and RemoveResults features (hard-coded here in order not to change the data model).
             # For all other features, just keep their name.
             if theForce or theFeature.isInHistory() or aFeatureKind=="Export" or aFeatureKind=="RemoveResults":
-                self.myFeatures[aFeatureKind](theFeature).dump(self)
+                aDumper = self.myFeatures[aFeatureKind](theFeature)
+                # Dump comment for the operation before the dumping of the feature to improve the readability of a script.
+                if self.dumpCommentBeforeFeature(theFeature):
+                    self.__print__("\n### Create " + theFeature.getKind())
+                    self.newline()
             else:
                 self.name(theFeature)
                 self.clearNotDumped()
         else:
             # Probably the feature is a constraint, try to dump it with SketchAPI_Constraint.
             # In case of theFeature is not a constraint, it will not be dumped.
-            self.myFeatures[SketchAPI.SketchAPI_Constraint.ID()](theFeature).dump(self)
+            self.name(theFeature, False, True, True)
+            aDumper = self.myFeatures[SketchAPI.SketchAPI_Constraint.ID()](theFeature)
+        if aDumper is not None:
+            aDumper.dump(self)
 
     ## Create wrapper for a folder and dump it
     def dumpFolder(self, theFolder):
index b09ec6de740ebed346e8f26cef99921d7572c7c5..9b0fb1827cdc663caf1a6422fdabf11942bf3b99 100644 (file)
@@ -194,7 +194,7 @@ void SketchAPI_Constraint::dump(ModelHighAPI_Dumper& theDumper) const
     return;
 
   const std::string& aSketchName = theDumper.parentName(aBase);
-  theDumper << aBase << " = " << aSketchName << "." << aSetter << "(";
+  theDumper << aSketchName << "." << aSetter << "(";
 
   bool isFirstAttr = true;
   for (int i = 0; i < CONSTRAINT_ATTR_SIZE; ++i) {
index 038ee0c15a8ac08cf174adf1998877d11f12f7c9..c9abfa460507829f66264b521efddac8b96b523d 100644 (file)
@@ -129,7 +129,8 @@ void SketchAPI_ConstraintAngle::dump(ModelHighAPI_Dumper& theDumper) const
   FeaturePtr aBase = feature();
 
   const std::string& aSketchName = theDumper.parentName(aBase);
-  theDumper << aBase << " = " << aSketchName << "." << "setAngle(";
+  theDumper.name(aBase, false, true, true); // mark constraint as dumped
+  theDumper << aSketchName << "." << "setAngle(";
 
   bool isFirstAttr = true;
   for (int i = 0; i < CONSTRAINT_ATTR_SIZE; ++i) {