GSoC 2020: A better IPython and Jupyter Notebook Integration for FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: GSoC 2020: A better IPython and Jupyter Notebook Integration for FreeCAD
After our discussion yesterday I looked up the handling of normals. In coin they are specified via a SoNormal node, and an accompying SoNormalBinding node. For example see the Part Workbench Viewprovider.
You can extract the normals there without the need to recompute them yourself. That should give more accurate results, as the normals come from the shape directly and hence are more accurate.
You can extract the normals there without the need to recompute them yourself. That should give more accurate results, as the normals come from the shape directly and hence are more accurate.
- kryptokommunist
- Posts: 70
- Joined: Fri Mar 27, 2020 6:29 pm
- Location: Berlin
- Contact:
Re: GSoC 2020: A better IPython and Jupyter Notebook Integration for FreeCAD
Thanks to Werner I have this information now.kryptokommunist wrote: ↑Wed Jul 29, 2020 12:35 am
- find out where in FreeCAD I can access the names of edges and surfaces
- extending my current pythreejs scene graph function to attach labels to it's surfaces and edges
I slightly varied the approach to selection of edges and faces. The basic functionality on pythreejs is working. I still have to link it up to the FreeCAD edge and face labels. Implementing this entirely on the Javascript side is a task I would take on in the future since there are still some issues on integrating that cleanly with the library. Currently the best way for highlighting I could get working is replacing the entire scene. Just changing the colour of a single object I couldn't get to work yet, therefore the flickering after selection. That also makes highlighting on hovering over the object very unpleasant. Therefore I will stick to clicking for now.
Kinda done, I still have to modify the mouse panning inside the 3D view to pan the object only and not the entire universe as currently (this means the lighting is fixed relative to the object which does not match the desktop apps 3D view).
- hard copy default camera, lighting defaults from FreeCAD
My goals for this week are (kanban link)
- Matching and displaying the correct FreeCAD labels when selecting or hovering over the objects in the pythreejs 3D view
- create example files for various workbenches and test them
- fix edge bug (currently the displayed edges don't fully match the desktop 3D view
Last edited by kryptokommunist on Fri Aug 21, 2020 11:59 pm, edited 4 times in total.
-
- Posts: 6
- Joined: Fri Aug 14, 2020 12:40 pm
Re: GSoC 2020: A better IPython and Jupyter Notebook Integration for FreeCAD
Hi there,
Jupyter core developer here - I am thrilled to see work being done to better integrate FreeCAD and Jupyter!
We have been working with some folks at Kitware on a similar problem to integrate Jupyter with the Python interpreter embedded into Slicer3D. (Check out our blog post: https://blog.jupyter.org/slicerjupyter- ... 2ad829f635). Also, I see that you are making use of ipywidgets and pythreejs for the rendering.
We would love to help! Besides, I think that this kind of integration could be a good subject for a guest post on the Jupyter blog (blog.jupyter.org). Let us know if you would like to connect for a catch up over video some time in the next couple of weeks to discuss all of this in more detail!
Cheers,
Sylvain
Jupyter core developer here - I am thrilled to see work being done to better integrate FreeCAD and Jupyter!
We have been working with some folks at Kitware on a similar problem to integrate Jupyter with the Python interpreter embedded into Slicer3D. (Check out our blog post: https://blog.jupyter.org/slicerjupyter- ... 2ad829f635). Also, I see that you are making use of ipywidgets and pythreejs for the rendering.
We would love to help! Besides, I think that this kind of integration could be a good subject for a guest post on the Jupyter blog (blog.jupyter.org). Let us know if you would like to connect for a catch up over video some time in the next couple of weeks to discuss all of this in more detail!
Cheers,
Sylvain
- kryptokommunist
- Posts: 70
- Joined: Fri Mar 27, 2020 6:29 pm
- Location: Berlin
- Contact:
Re: GSoC 2020: A better IPython and Jupyter Notebook Integration for FreeCAD
Hi Sylvain,SylvainCorlay wrote: ↑Fri Aug 14, 2020 12:55 pm (Check out our blog post: https://blog.jupyter.org/slicerjupyter- ... 2ad829f635). Also, I see that you are making use of ipywidgets and pythreejs for the rendering.
the Slicer looks great! Currently the notebook integration approach with FreeCAD is simply ignoring the entire QT event loop. This way FreeCAD can be loaded and used just like any python library. My work here is visualizing the 3D and other data present. But knowing how the QT loop could be integrated would be valuable since there are some FreeCAD functionalities that require running the QT event loop. Still the functionality without it is already powerful (my impression so far).
Sounds good, I'm happy to discuss the implementation and where I could use some help from you guys. I ran into some problems with customising widgets. And the blog offer would be perfect I'll send you my contacts via PM.We would love to help! Besides, I think that this kind of integration could be a good subject for a guest post on the Jupyter blog (blog.jupyter.org). Let us know if you would like to connect for a catch up over video some time in the next couple of weeks to discuss all of this in more detail!
Last edited by kryptokommunist on Mon Aug 17, 2020 4:45 pm, edited 2 times in total.
- kryptokommunist
- Posts: 70
- Joined: Fri Mar 27, 2020 6:29 pm
- Location: Berlin
- Contact:
Re: GSoC 2020: A better IPython and Jupyter Notebook Integration for FreeCAD
Here is a demo on using interactive widgets that control FreeCAD. Really great way to quickly build custom interactive UI for work with FreeCAD. The code can be found at the bottom of the notebook.
- kryptokommunist
- Posts: 70
- Joined: Fri Mar 27, 2020 6:29 pm
- Location: Berlin
- Contact:
Re: GSoC 2020: A better IPython and Jupyter Notebook Integration for FreeCAD
Done. (Will upload demo later) Thanks to a very helpful tip from @ickby this is correct and matches the FreeCAD indices. Still need to implement edge indices, but this should be very similar.kryptokommunist wrote: ↑Wed Jul 29, 2020 12:35 am
- Matching and displaying the correct FreeCAD labels when selecting or hovering over the objects in the pythreejs 3D view
Still working on this.
- create example files for various workbenches and test them
- fix edge bug (currently the displayed edges don't fully match the desktop 3D view
I have not solved this yet, but I will debug this using simple geometries as suggested by @ickby.
My goals for this week are (kanban link)
- Enable line selection equivalent to the face selection
- create example files for various workbenches and test them
- fix edge bug (currently the displayed edges don't fully match the desktop 3D view
Re: GSoC 2020: A better IPython and Jupyter Notebook Integration for FreeCAD
Good to hear the selection works!
- kryptokommunist
- Posts: 70
- Joined: Fri Mar 27, 2020 6:29 pm
- Location: Berlin
- Contact:
Re: GSoC 2020: A better IPython and Jupyter Notebook Integration for FreeCAD
kryptokommunist wrote: ↑Fri Aug 21, 2020 11:53 pmkryptokommunist wrote: ↑Wed Jul 29, 2020 12:35 amDone. (Will upload demo later) Thanks to a very helpful tip from @ickby this is correct and matches the FreeCAD indices. Still need to implement edge indices, but this should be very similar.
- Matching and displaying the correct FreeCAD labels when selecting or hovering over the objects in the pythreejs 3D view
We are now in the final week and the face highlighting now works correctly and after some input from @ickby on the last call I finally managed to get rid of the edge bug and as you can see the edges are now rendered as they appear in FreeCAD:
So for the final week I intend to get these points done (kanban link):
- Enable line selection/highlighting equivalent to the face selection
- Enable vertice selection/highlighting equivalent to the face selection
- package everything up into an class that can be used as FreeCAD Add On or similar easy to use scheme
- Extend documentation and add a clean example Notebook
- Write Blogpost or create a Video demoing the result (will discuss this with the mentors)
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: GSoC 2020: A better IPython and Jupyter Notebook Integration for FreeCAD
Question will it work with Part::FeaturePython objects?
With my GDML workbench https://github.com/KeithSloan/GDML Graphic objects are implemented as Part::FeaturePython Objects and it would be great to create Models/Designs via programming in a Jupyter notebook.
I suspect I would have to add some new function definitions to make this easy as at present functions tend to access lxml Elements, but it should be easy enough for me to add functions that just rely on passed python variables.
If you have any spare time after you finish it would be good to have a Skype or similar session to discuss.
With my GDML workbench https://github.com/KeithSloan/GDML Graphic objects are implemented as Part::FeaturePython Objects and it would be great to create Models/Designs via programming in a Jupyter notebook.
I suspect I would have to add some new function definitions to make this easy as at present functions tend to access lxml Elements, but it should be easy enough for me to add functions that just rely on passed python variables.
If you have any spare time after you finish it would be good to have a Skype or similar session to discuss.
- kryptokommunist
- Posts: 70
- Joined: Fri Mar 27, 2020 6:29 pm
- Location: Berlin
- Contact:
Re: GSoC 2020: A better IPython and Jupyter Notebook Integration for FreeCAD
That is a very good question, as one goal of the project was to have general solution that would mostly copy the view this might work just out of the box. But I didn't get to testing things outside of Part Workbench generated Objects. As far as I understand most Workbenches just recycle the Part API to create their objects. If at least the structure of the Coin3D graph being generated is similar it should work out of the box. In the scene graph to my current understanding there are ultimately just Faces, Lines and Points and that's what the project can currently render. So in the end it might need some tweaking of where the Jupyter 3D view renderer will look in the scene graph to display your objects, but no special functions from your side.keithsloan52 wrote: ↑Sat Aug 29, 2020 5:28 am I suspect I would have to add some new function definitions to make this easy as at present functions tend to access lxml Elements, but it should be easy enough for me to add functions that just rely on passed python variables.
If you have any spare time after you finish it would be good to have a Skype or similar session to discuss.
Only you'd need to make sure that your workbench will run headless in the sense that the QT loop won't run.