Offline Rendering Utils - Request for testing

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
Site Admin
Posts: 11618
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil

Offline Rendering Utils - Request for testing

Postby yorik » Sun Jun 30, 2019 12:31 am

In git commit fe3cb2f0e, I added a new file to the Arch module, called, that contains several tools to ease exporting files from FreeCAD running in non-GUI mode, namely export files with colors.

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: ...

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:

Code: Select all

    Section "ServerFlags"  
        Option "AllowIndirectGLX" "on"  
        Option "IndirectGLX" "on"  
(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"

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...)

Code: Select all

# if needed, add the path to your or FreeCAD.pyd
import sys

import FreeCAD
import OfflineRenderingUtils
This should produce a /path/to/some/test.png file that shows a grey cube on a white background like this:
colors.png (2.07 KiB) Viewed 181 times
If anything goes wrong, you should see some error messages.