Callbacks and visualisation


User question:

A general question that I have is related with the software you use to actually run the applications. I was using Spyder (that came with Anaconda) and it works pretty well for the construction of meshes, Delaunay applications, remeshing, finding the shortest-path etc. However, every time that I tried to execute the algorithms (code with “animation”/ usually codes with callback) the application would give me errors. In these cases, I tried to run the code directly from the command prompt which would open a new window (Mesh Plotter, Network Plotter, for example…) and then it would work. However, in other cases this window would crash not showing me anything. Would you have a clue of what this is happening? And do you open the Command Prompt every time before running a new application? (PS: I am a windows user)


Spyder is a good IDE (integrated development environment), especially for utilising the Anaconda pre-installed packages, such as NumPy, SciPy, matplotlib etc. It sounds like the matplotlib type examples are working well with you, these are those based on the Plotter which uses matplotlib as a backend, this includes also the NetworkPlotter and MeshPlotter.

It is most likely that anything that involves a callback is trying to plot an iteration in some loop of an algorithm. This is often used to visualise something in 3D, either via Rhino or the Viewer, NetworkViewer or MeshViewer, the latter three utilise a different engine, PyOpenGL, which may or may not be installed for you. Check with:

pip show pyopengl  # Python 2
pip3 show pyopengl  # Python 3

or look in the Anaconda Navigator to see if it is installed. I have found that with Spyder/Anaconda on Windows I have had to install PyOpenGl myself for good results. In Windows I would recommend a .whl file from here, as we have found that a pip install doesn’t always work well.


hi all,

Spyder is indeed convenient if you are looking for a Matlab-style environment and I am sure it has a lot of powerful features. However, the version of Spyder that ships with Anaconda3 seems to still have a few problems. And it might not be the most flexible setup for using COMPAS.

in general i would recommend using something like Sublime Text or Atom. perhaps this requires a little more configuration, but really only a little more, and it is an investment that will pay off in the long run.

admittedly, the COMPAS docs are currently still a bit sparse on information about getting a flexible development environment running smoothly with these kind of tools, but that information is coming soon.

the idea behind the example snippets below the if-name-is-main guards at the bottom of the modules in COMPAS is indeed that you can quickly execute the modules as scripts to get an idea of the functionality available in the module.

executing the modules as scripts is possible from the previously mentioned editors in the same way as from Spyder, but should work without the problems you have experienced. in any case, Spyder will not be very useful for running interactive plots or for visualisations with 3D viewers. running scripts from the command line is also an option as you mentioned, but perhaps a bit tedious…