Example of Successive Animation:
import os from time import sleep import salome import VISU from visu_gui import * # The directory containing MED files datadir = os.getenv("DATA_DIR") # Import a MED file medFile = os.path.join(datadir,"MedFiles","TimeStamps.med") myResult = myVisu.ImportFile(medFile) # Create a 3D view myViewManager = myVisu.GetViewManager() myView = myViewManager.Create3DView() myView.SetTitle("Animation view") # Create an animation instance fieldName = "vitesse" myAnimation = myVisu.CreateAnimation(myView); # Set the successive animation mode myAnimation.setAnimationMode(VISU.Animation.SUCCESSIVE) # Set the animation properties: # Add a field with timestamps, on which the animation will be performed fieldName = "vitesse, m/s" fieldSO = salome.myStudy.FindObject(fieldName) myAnimation.addField(fieldSO) # Set the presentation type for the first field myAnimation.setPresentationType(0, VISU.TDEFORMEDSHAPEANDSCALARMAP) # Generate presentations myAnimation.generatePresentations(0) # Create the pattern of a Deformed Shape and Scalar Map presentation meshName = "dom" fieldName = "vitesse" fieldEntity = VISU.NODE timestampId = 1 myDefShapeScalarMap = myVisu.DeformedShapeAndScalarMapOnField(myResult, meshName, fieldEntity, fieldName, timestampId) myDefShapeScalarMap.SetScale(0.75) # Apply the pattern properties to all generated presentations myAnimation.ApplyProperties(0, myDefShapeScalarMap) # Generate frames myAnimation.generateFrames() # Publish the animation object in the study myAnimation.publishInStudy() # Set the speed myAnimation.setSpeed(80) # Save the animation after changing the speed myAnimation.saveAnimation() # Fit All myView.FitAll() # Start the animation myAnimation.startAnimation() # Rewind to the first frame sleep(10) myAnimation.firstFrame() # Update the object browser salome.sg.updateObjBrowser(1)
Example of Parallel Animation:
import os from time import sleep import salome import VISU from visu_gui import * # The directory containing MED files datadir = os.getenv("DATA_DIR") # Import a MED file medFile = os.path.join(datadir,"MedFiles","TimeStamps.med") myResult = myVisu.ImportFile(medFile) # Create a 3D view myViewManager = myVisu.GetViewManager() myView = myViewManager.Create3DView() myView.SetTitle("Animation view") # Create an animation instance fieldName = "vitesse" myAnimation = myVisu.CreateAnimation(myView); # Set the successive animation mode myAnimation.setAnimationMode(VISU.Animation.PARALLEL) # Set animation properties: # Add two fields with timestamps, on which the animation will be performed fieldName1 = "vitesse, m/s" fieldSO1 = salome.myStudy.FindObject(fieldName1) fieldName2 = "temperature, K" fieldSO2 = salome.myStudy.FindObject(fieldName2) myAnimation.addField(fieldSO1) myAnimation.addField(fieldSO2) # Set the presentation type for the first field myAnimation.setPresentationType(0, VISU.TVECTORS) # Set the presentation type for the second field myAnimation.setPresentationType(1, VISU.TSCALARMAP) # Generate presentations for all fields nbFileds = myAnimation.getNbFields() for i in range(0, nbFileds): myAnimation.generatePresentations(i) # Create the pattern of Vectors presentation meshName = "dom" fieldName = "vitesse" fieldEntity = VISU.NODE timestampId = 1 myVectors = myVisu.VectorsOnField(myResult, meshName, fieldEntity, fieldName, timestampId) myVectors.SetScale(1) myVectors.ShowColored(True) # Apply the vectors pattern properties to all presentations generated for 'vitesse' field myAnimation.ApplyProperties(0, myVectors) # Generate frames myAnimation.generateFrames() # Publish the animation object in the study myAnimation.publishInStudy() # Set the speed myAnimation.setSpeed(95) # Fit All myView.FitAll() # Start the animation myAnimation.startAnimation() # Update the object browser salome.sg.updateObjBrowser(1)
Please, see Animation interface reference documentation for more details.