Regarding your fix to the Draft Array tool, that seems perfect (thanks @vocx for the review)! In any case it demonstrates perfectly that you can find your way around FreeCAD, and with this community. I think this fullfills perfectly what is expected from this GSOC bonding period.
Regarding jupyter and 3D export of the FreeCAD scene, a couple of preliminary ideas:
I think there are two strategies to choose. Currently,if you don't have the GUI open, although you are able to import and manipulate somehow the FreeCADGui module, you don't have all the visual settings of objects. The only way to achieve that is to show the FreeCAD GUI, even if hiding it immediately afterwards, to turn on all the Qt events loop. See examples in
this thread (old, but the concept is still valid).
So I think you have to choose here between 1) not using the GUI module, and building alternative ways to manage visual info (colors, etc) or 2) using the GUI and finding ways to minimize/address the problem. Might be quickly show/hide the GUI, or anything else.
I think both ways are valid. 1) would be quicker, would allow you to work fully in Python, and is not necessarily a bad way at all. Even without the GUI, you would still be able to do almost everything you need. Check the
OfflineRenderingUtils.py, it contains much stuff already to works that way. One way I'm imagining this could work is basically to have a special module (or even add methods at runtime to the GUI module), that would allow someone, inside jupyter to do something like this:
Code: Select all
import FreeCAD
import Part
import FreeCADJupyterTools
d = FreeCAD.newDocument()
sh = Part.makeSphere(10)
obj = d.addObject("Part::Feature","MySphere")
obj.Shape = sh
print(obj.ViewObject) # this returns None as the GUI is not used
FreeCADJupyterTools.setColor(obj,(1.0,0.0,0.0)) # this would store the obj/color relationship somewhere. Maybe even in the object itself
FreeCADJupyterTools.render(d) # this would show the webGL scene inside the notebook
2) The second way is more in sync with what oyu wrote in your GSOC proposal, basically a way to have this:
Code: Select all
import FreeCADGui
# here at the moment you need to do this to trigger ViewObjects functionality
FreeCADGui.showMainWindow()
mw = FreeCADGui.getMainWindow()
mw.hide()
obj.ViewObject.ShapeColor = (1.0,0.0,0.0)
Then you could gather the coin nodes from every object (obj.ViewObject.RootNode) and have a coin-to-webgl conversion happen.
Note that Shape and Mesh objects (such as 'sh' in the example above) all have a writeInventor() method, that outputs a very simple inventor node (without any material), that is less refined than from obj.ViewObject.RootNode, but that might be totally sufficient to start with, so even with method 1), a coin-to-webgl convertor seems a good way to follow.
The only FreeCAD objects that have no Shape or Mesh are very few, basically some Draft objects (texts, dimensions) and Path. But for all these, it might not be hard to do the same thing as above, basically add some writeInventor() method to them.