IPython notebook integration: Difference between revisions

From FreeCAD Documentation
mNo edit summary
No edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 2: Line 2:


==Outline==
==Outline==
FreeCAD is quite popular for its extensive python API providing grounds for many advanced macros and extensions. The API, which exposes everything from the document structure, basic workbench specific types and even the whole GUI, offers large amounts of freedom for the user to create everything he wants. Python in itself has become increasingly popular in the scientific community over the last years, partially surparsing classical interpretet languages like Matlab in certain areas. Due to this increased interest in and usage of the language an ecosystem for scientific computation has evolved around python, leading to advanced coding environments like IPython and its Jupyter notebook. As this scientific usage of the language fits very well into FreeCADs profile as a python driven CAx application it should be possible to tightly integrate it into the scientific workflow. This means less usage of an custom application GUI but good integration into multi-purpose computation environments like IPython.
FreeCAD is quite popular for its extensive Python API providing grounds for many advanced macros and extensions. The API, which exposes everything from the document structure, basic workbench specific types and even the whole GUI, offers large amounts of freedom for the user to create everything he wants. Python in itself has become increasingly popular in the scientific community over the last years, partially surpassing classical interpreted languages like Matlab in certain areas. Due to this increased interest in and usage of the language an ecosystem for scientific computation has evolved around Python, leading to advanced coding environments like IPython and its Jupyter notebook. As this scientific usage of the language fits very well into FreeCADs profile as a python driven CAx application it should be possible to tightly integrate it into the scientific workflow. This means less usage of a custom application GUI but good integration into multi-purpose computation environments like IPython.


FreeCADs API in itself is solid and powerfull enough to be used in IPython extensively, however, one main issue with CAx code is the visualisation. It is nearly impossible to develop 3D models without seeing them. It is therefore important to find a way to visualize FreeCADs 3D scene in the IPython display system as supported by the IPython QTConsole and the Jupyter notebook.
FreeCAD's API in itself is solid and powerful enough to be used in IPython extensively, however, one main issue with CAx code is the visualisation. It is nearly impossible to develop 3D models without seeing them. It is therefore important to find a way to visualize FreeCAD's 3D scene in the IPython display system as supported by the IPython QTConsole and the Jupyter notebook.


==Details==
==Details==
Line 11: Line 11:
#Write a openinventor action writing the JavaScript file which mimics the scene graph from the open inventor representation
#Write a openinventor action writing the JavaScript file which mimics the scene graph from the open inventor representation
##It should export geometry nodes as well as material (color etc.), lightning and camera
##It should export geometry nodes as well as material (color etc.), lightning and camera
##Advanced: Implement an replacement for all openinventor nodes
##Advanced: Implement a replacement for all openinventor nodes
#Create a real JavaScript 3D viewer which mimics FreeCAD viewer
#Create a real JavaScript 3D viewer which mimics FreeCAD viewer
##It should support 3D navigation, standart views (top, bottom,...)
##It should support 3D navigation, standard views (top, bottom,...)
##Advanced: It should mimic the FreeCAD preselection, e.g. show edges, faces and vertices as they are in FreeCAD
##Advanced: It should mimic the FreeCAD preselection, e.g. show edges, faces and vertices as they are in FreeCAD
##Advanced: It should show the correct geometry names as in FreeCAD when preselected
##Advanced: It should show the correct geometry names as in FreeCAD when preselected
Line 21: Line 21:


==Expected Outcome==
==Expected Outcome==
#The possibility to easily show FreeCAD document objects in Jupyter without needing to fire up the FreeCAd GUI
#The possibility to easily show FreeCAD document objects in Jupyter without needing to fire up the FreeCAD GUI
#The possibility to comfortably navigate the 3D scene inside of Jupyter
#The possibility to comfortably navigate the 3D scene inside of Jupyter
#Better WebGL export
#Better WebGL export
#documentation of the FreeCAD IPython interoperability in the Wiki and an example Jupyter notebook.
#Documentation of the FreeCAD IPython interoperability in the Wiki and an example Jupyter notebook.


==Future Possibilities==
==Future Possibilities==
Line 38: Line 38:


===Additional Information===
===Additional Information===
* Ticket on FreeCAD bug tracker: [https://freecadweb.org/tracker/view.php?id=2869 #2869]
* A FreeCAD kernel for Jupyter: [https://github.com/looooo/jupyter_freecad_kernel looooo/jupyter_freecad_kernel]
* Dedicated discussion: [http://forum.freecadweb.org/viewtopic.php?f=22&t=14740 IPython notebook integration]
* Thread discussion: [https://forum.freecadweb.org/viewtopic.php?f=22&t=38976 How to use Jupyter Notebook with FreeCad (Guide)]
* Thread discussion: [https://forum.freecadweb.org/viewtopic.php?t=13620 Embedding FreeCAD in IPython]
* Thread discussion: [https://forum.freecadweb.org/viewtopic.php?t=38217 Has Anyone successfully connected to FC thru Jupyter ?]
* Thread discussion: [https://forum.freecadweb.org/viewtopic.php?f=10&t=14166 IPython Qt Console]


[[Category:Google Summer of Code]]
* A discussion about this project in the forum: [http://forum.freecadweb.org/viewtopic.php?f=22&t=14740 Discussion]
[[Category:Developer]]
[[Category:Python Code]]


==GSoC 2020==


This project was chosen for GSoC 2020. The results can be found here: [https://github.com/kryptokommunist/Jupyter_FreeCAD Git repo]. The corresponding thread in the FreeCAD forum can be found [https://forum.freecadweb.org/viewtopic.php?f=8&t=46039 here]. Find a blog post [https://kryptokommun.ist/tech/2020/08/31/google-summer-of-code.html here]. The full project proposal can be found [https://docs.google.com/document/d/1VgfsD06Qvb87S-tQazfTsyYTp14Z3EjF4V9puPVNCTQ/edit here]. The results are a good base to build upon.
[[Category:Google Summer of Code]]

Latest revision as of 11:02, 31 August 2020

This page is dedicated to the Google Summer of Code project regarding the interoperability between IPython and FreeCAD, mostly regarding visualisation.

Outline

FreeCAD is quite popular for its extensive Python API providing grounds for many advanced macros and extensions. The API, which exposes everything from the document structure, basic workbench specific types and even the whole GUI, offers large amounts of freedom for the user to create everything he wants. Python in itself has become increasingly popular in the scientific community over the last years, partially surpassing classical interpreted languages like Matlab in certain areas. Due to this increased interest in and usage of the language an ecosystem for scientific computation has evolved around Python, leading to advanced coding environments like IPython and its Jupyter notebook. As this scientific usage of the language fits very well into FreeCADs profile as a python driven CAx application it should be possible to tightly integrate it into the scientific workflow. This means less usage of a custom application GUI but good integration into multi-purpose computation environments like IPython.

FreeCAD's API in itself is solid and powerful enough to be used in IPython extensively, however, one main issue with CAx code is the visualisation. It is nearly impossible to develop 3D models without seeing them. It is therefore important to find a way to visualize FreeCAD's 3D scene in the IPython display system as supported by the IPython QTConsole and the Jupyter notebook.

Details

  1. Get familiar with FreeCADs openinventor scenegraph and the basic working of the GUI module. Also learn the openinventor API and the scene graph structure it provides.
  2. Find a JavaScript library which makes it easy to create 3D scene graphs via WebGL and analyse how the nodes can be mapped to the open inventor scene graph nodes. A good candidate is SceneJS
  3. Write a openinventor action writing the JavaScript file which mimics the scene graph from the open inventor representation
    1. It should export geometry nodes as well as material (color etc.), lightning and camera
    2. Advanced: Implement a replacement for all openinventor nodes
  4. Create a real JavaScript 3D viewer which mimics FreeCAD viewer
    1. It should support 3D navigation, standard views (top, bottom,...)
    2. Advanced: It should mimic the FreeCAD preselection, e.g. show edges, faces and vertices as they are in FreeCAD
    3. Advanced: It should show the correct geometry names as in FreeCAD when preselected
    4. Advanced: Implement multiple navigation modes
  5. Extend FreeCAD with functions returning an IPython compatible version of the created JavaScript 3D viewer
  6. Replace the current WebGL export with the new advanced component

Expected Outcome

  1. The possibility to easily show FreeCAD document objects in Jupyter without needing to fire up the FreeCAD GUI
  2. The possibility to comfortably navigate the 3D scene inside of Jupyter
  3. Better WebGL export
  4. Documentation of the FreeCAD IPython interoperability in the Wiki and an example Jupyter notebook.

Future Possibilities

If the 3D scene can be navigated other things, which FreeCAD can display, remain, for example the spreadsheet.

Project Properties

Skills

  • Programming language mainly C++ and JavaScript
  • Understand and use APIs from FreeCAD and external libraries like openinventor

Difficulty

Easy

Additional Information

GSoC 2020

This project was chosen for GSoC 2020. The results can be found here: Git repo. The corresponding thread in the FreeCAD forum can be found here. Find a blog post here. The full project proposal can be found here. The results are a good base to build upon.