]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fixes in python code to avoid modifications outside of a transaction:
authorsbh <sergey.belash@opencascade.com>
Mon, 24 Nov 2014 11:39:43 +0000 (14:39 +0300)
committersbh <sergey.belash@opencascade.com>
Mon, 24 Nov 2014 11:39:43 +0000 (14:39 +0300)
# Implicit calls of startOperation/finishOperation removed
# Method for "ConstraintLength" created inside of sketch API module
# C++ API corrected to avoid hangs on modifications outside of a transaction

src/Events/Events_Loop.cpp
src/PythonFeaturesPlugin/examples.py
src/PythonFeaturesPlugin/sketch.py

index eadae7283f44541edb18b0a29c53404ef304d891..189516ae090cd9c97882d3015b61b3508bee85eb 100644 (file)
@@ -122,7 +122,9 @@ void Events_Loop::flush(const Events_ID& theID)
     boost::shared_ptr<Events_Message> aGroup = aMyGroup->second;
     myGroups.erase(aMyGroup);
     send(aGroup, false);
-    myFlushed.erase(myFlushed.find(theID.myID));
+    std::set<char*>::iterator anIt = myFlushed.find(theID.myID);
+    if (anIt != myFlushed.end())
+      myFlushed.erase(myFlushed.find(theID.myID));
   }
 }
 
index 75c5e7733ceff43b6dbb45f11e9975d15d202bd4..d2279de34b4c09f4f5a879176adb44e8b5fbcf4e 100644 (file)
@@ -1,35 +1,28 @@
 from ModelAPI import *
+from SketchResult import *
 import sketch
 import extrusion
-from SketchResult import *
 #reload(sketch) # Pour tester plus facilement
 #reload(extrusion) # Pour tester plus facilement
 
 def makeBox(aLength, aWidth, aHeight):
-  print "makeBox"
   # Getting the active document
-
   session = ModelAPI_Session.get()
   part = session.activeDocument()
 
-
   # Starting the Sketch
-
-  session.startOperation()
   base = sketch.addTo(part)
   sketch.setXOYPlane(base)
 
-
   # Creating the lines
-
-  l1  = sketch.addLine(10, 10, 10, 50, base)
-  l2  = sketch.addLine(10, 50, 60, 60, base)
-  l3  = sketch.addLine(60, 60, 50, 10, base)
-  l4  = sketch.addLine(50, 10, 10, 10, base)
+  l1 = sketch.addLine(10, 10, 10, 50, base)
+  l2 = sketch.addLine(10, 50, 60, 60, base)
+  l3 = sketch.addLine(60, 60, 50, 10, base)
+  l4 = sketch.addLine(50, 10, 10, 10, base)
+  base.execute()
 
 
   # Creating the constraints
-  
   # NOTE : the following lines are currently not working in BR_PYTHON_PLUGIN branch
   """
   sketch.makeCoincident(sketch.getEndPoint(l1), sketch.getStartPoint(l2), base)
@@ -44,12 +37,10 @@ def makeBox(aLength, aWidth, aHeight):
   """
 
   # Finalisation of the operation
-  
   builder = SketchResult(base)
 
   # Creating a feature Extrusion
   box = extrusion.addNew(builder, 50, part)
-  session.finishOperation()
 
   #return base.lastResult()
   return extrusion.getBody(box)
index 462c1808aa09bee17b119b7f67aee94ba692b94b..6d002d3070afb7c8d52f4de95a41a6b805803d8a 100644 (file)
@@ -82,7 +82,7 @@ def addLine(x1, y1, x2, y2, sketch):
 
 
 def getGeometry(line):
-  return line.firstResult()
+  return modelAPI_ResultConstruction(line.firstResult())
 
 
 def getStartPoint(line):
@@ -112,3 +112,8 @@ def makePerpendicular(l1, l2, sketch):
   constraint  = sketch.addFeature("SketchConstraintPerpendicular")
   constraint.refattr("ConstraintEntityA").setObject(l1)
   constraint.refattr("ConstraintEntityB").setObject(l2)
+
+def makeConstantLength(line, length, sketch):
+  constraint = sketch.addFeature("SketchConstraintLength")
+  constraint.refattr("ConstraintEntityA").setObject(line)
+  constraint.real("ConstraintValue").setValue(length)