Animate Simulation Results in Batch Using Compose and HyperView
Altair Compose is a tool that can enhance our usage of other simulation tools. In this small post I will show you how you can use it to run multibody systems simulations using MotionSolve and animate your results in HyperView, all with a single click.
This example is based on the Python script shown in Drive MotionSolve Simulations with Python and Altair Compose. Although an OML script is used here, the process is equivalent. Look at the previous article for a thorough script explanation. Here I will only focus on calling HyperView Player in batch.
HyperView Player is called with the executable file found at your Altair installation directory, so the path might look like "C:\Program Files\Altair\2024\hwdesktop\hw\bin\win64\hvp.exe". Syntax for a batch call requires the H3D file as well. E.g., a command like this in the command prompt:
"C:\Program Files\Altair\2024\hwdesktop\hw\bin\win64\hvp.exe" "C:\Users\rsanchez\batch_animate\SpringMass.h3d"
Would launch the HyperView player and animate the results contained in SpringMass.h3d.
We can leverage terminal commands in Compose with the system function. In this case, required inputs are the desired command, as a string, and a flag for executing asynchronously so control is returned to the script after executing the command.
As an important note, everytime you call Altair tools from Compose, empty the contents of environment variable ALTAIR_HOME, as shown in the following chunk of code:
% Display animations
h3dPlayer = fullfile(altairFolder, 'hwdesktop\hw\bin\win64\hvp.exe');
for i = 1:numel(resFiles)
h3dFile = strrep([resFiles{i} '.h3d'], '\', '/');
command = sprintf('"%s" "%s"', h3dPlayer, h3dFile);
system(['set ALTAIR_HOME=& ', command], 'async');
end
These OML commands iterate over all the result files of interest and launches HyperView Player. Running the full script will compile all MBD models, simulate and animate results. You will end up with something like this:
I hope this very small example helps you get started using Compose to accelerate your simulation workflows. The script, input and model files needed for replicating are attached to this article.
Reach out in the community product forums if you are having issues leveraging Compose in this way. Alternatively, email hwsupport@altair.com or reach out for support from your Altair One account if you need assistance from experts.