Salome HOME
Make preview of python Box feature working correctly
authormpv <mpv@opencascade.com>
Thu, 19 Mar 2015 09:46:34 +0000 (12:46 +0300)
committermpv <mpv@opencascade.com>
Thu, 19 Mar 2015 09:46:34 +0000 (12:46 +0300)
src/PythonFeaturesPlugin/PythonFeaturesPlugin_Box.py

index 2487a6ee882133ac23c0a13f6168674cc49757e4..fd56863552bdbff24c8deb4ff5ad4359ae8e17d5 100644 (file)
@@ -136,7 +136,7 @@ class PythonFeaturesPlugin_Box(ModelAPI.ModelAPI_CompositeFeature):
         return subsCount
 
     def subFeature(self, theIndex):
-        if theIndex == 1: # sketch
+        if theIndex == 0: # sketch
             return ModelAPI.compositeFeatureToFeature(self.mySketch)
         return self.myExtrusion
 
@@ -146,6 +146,15 @@ class PythonFeaturesPlugin_Box(ModelAPI.ModelAPI_CompositeFeature):
     def isSub(self, theFeature):
         return theFeature == self.mySketch or theFeature == self.myExtrusion
 
+    def attributeChanged(self, theAttrID):
+        # on update of attributes values, transfer them to sub-features immideately to see good preview
+        # otherwise these features will be executed before execute of "Box" and with old parameters
+        aWidthRefValue = self.reference(self.WIDTH_REF_ID()).value()
+        aLengthRefValue = self.reference(self.LENGTH_REF_ID()).value()
+        aHeightRefValue = self.reference(self.HEIGHT_REF_ID()).value()
+        if all((aWidthRefValue, aLengthRefValue, aHeightRefValue)):
+          self.execute()
+
 # TEST
 """
 if __name__=='__main__':