Basically you can export IFC, DAE, OBJ, STEP or PNG or even FCStd files from the command line, with the object colors saved. You must provide the colors yourself, as a dict. This is mostly useful for servers running FreeCAD to produce files.
Mostly everything is explained in the file itself: https://github.com/FreeCAD/FreeCAD/blob ... ngUtils.py
One feature is failing on some machines and not on others, though: the PNG export, which is done with coin's offscreen rendering stuff.
Does anyone fancy testing this? curious to see where it works and where it doesn't...
1) The X server needs to have Indirect Rendering enabled. On recent distros, it seems to be disabled by default. The easiest way I found to fix this is to edit (or create if inexistant) /etc/X11/xorg.conf and add this:
(if your xorg.conf already has a "ServerFlags" section, just add the two options in it). There might be other ways for other distros though, google for "enable indirect glx"
Code: Select all
Section "ServerFlags" Option "AllowIndirectGLX" "on" Option "IndirectGLX" "on" EndSection
On windows I'm not sure if anything is needed... We'll see
2) In a python console running outside FreeCAD (this won't work inside FreeCAD, couldn't find out why yet...)
This should produce a /path/to/some/test.png file that shows a grey cube on a white background like this:
Code: Select all
# if needed, add the path to your FreeCAD.so or FreeCAD.pyd import sys sys.path.append("/path/to/FreeCAD.so") import FreeCAD import OfflineRenderingUtils OfflineRenderingUtils.render("/path/to/some/test.png")
If anything goes wrong, you should see some error messages.