Saturday, 13 September 2014

FreeCAD: simple Coin3d plot

Hi all: I'm back!

Some time ago, when I was investigating about octrees and voxels to create a true CNC simulator, I played a bit with Coin3d, the scene graph render of FreeCAD.
Coin3d is coded in C++, but can be accesed with Python using Pivy.

While I didn't find anything specially useful, I realized that one could easily plot math equations like this:

...which have a nice look and permit you to take curious snapshots, for example:

The code is:

from pivy import coin
sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()
print sg
for s in range(5):
  for n in range(-25,25):
    for i in range(-25,25):
      col = coin.SoBaseColor()
      trans = coin.SoTranslation()
      # equation: z = f( i, n ) s is to plot at several heights
      cub = coin.SoSphere()
      myCustomNode = coin.SoSeparator()

More info about FreeCAD and Coin3D, here