I just wanted to ask if someone already has experimented to replace the console of freecad with an ipython qt console? Any ideas what has to be changed to get this working? https://ipython.org/ipython-doc/2/interactive/qtconsole.html Or isn’t this possible?
Another cool thing would be to connect an ipython-notebook to freecad. This would provide some really great possibilities to work with freecad. (mathematica style inputs, inline plots, …)
This definitely crossed my mind, especially the notebook integration. But more on the side on howto show freecad visualisation in the notebook (and then of course also the QT console) via javascript. Would be awesome to have, as this would enable a better working in other scientific contexts. But I never even tried it, just one of the many things that come from time to time into my mind. Would be nice to investigate this
I tried to start ipython from the console but it has some problems with stdin.
>>> from IPython import embed
>>> embed()
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/IPython/terminal/embed.py", line 290, in embed
shell = InteractiveShellEmbed.instance(**kwargs)
File "/usr/lib/python2.7/dist-packages/IPython/config/configurable.py", line 354, in instance
inst = cls(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/IPython/terminal/embed.py", line 92, in __init__
display_banner=display_banner
File "/usr/lib/python2.7/dist-packages/IPython/terminal/interactiveshell.py", line 328, in __init__
**kwargs
File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 483, in __init__
self.init_readline()
File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 1884, in init_readline
self.refill_readline_hist()
File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 1893, in refill_readline_hist
stdin_encoding = sys.stdin.encoding or "utf-8"
Yes, I was able to import the FreeCAD module and played a bit with creating documents and adding objects. You have to search for ipython in the forum to get this topic.
When starting freecad from ipython the gui is always locked (grey). Using some code for embedding ipython I got a working console inside of freecad. Maybe something similar can be done with a notebook?
So here is a solution to start freecad from an ipython-qtconsole and ipython notebook. The trick was to place a %gui qt at the first line. Then the gui shows up. This is the code I have used now:
After starting freecad from the notebook, it is possible to show this notebook directly as a browser window in freecad, but I don’t know if this is useful.
With the normal ipython console I still get some errors:
Importing PySide disabled by IPython, which has
already imported an Incompatible QT Binding: pyqtv1
With some help of jupyter people I have made a small kernel, based on a ipython-kernel which starts FreeCAD at launch. If you want to try you need jupyter, clone this repo and run
(The freecadkernel.py file should be available to the import system of python. So palce it anywhere where python can find it) After starting a new notebook there should be the possibility to start a new FreeCAD kernel.
This cell based input is very useful for learning modules and trying new stuff. Also the auto-complete system seems a bit more advanced. The notebook also allows in-line plotting, showing svg’s, display latex… .
thanks. I will try to make a little video showing how to connect sympy mechanics from ipython notebook with FreeCAD. But first I have to learn sympy mechanics
Nice to see these interesting projects. Hopefully there will be many students working on FreeCAD this summer.
Here is a short notebook, which takes a box from FreeCAD, computes the motion due to gravity force with sympy.mechanics and PyDy (box is fixed at the origin) and visualize the rotation in FreeCAD.
Import Part in ipython console cause an Import error! //ImportError: /home/workspace/freecad-build/Mod/Part/Part.so: undefined symbol: _ZN7gp_Trsf9SetValuesEdddddddddddd // Why is this happening?
Import Part in ipython console cause an Import error! //ImportError: /home/workspace/freecad-build/Mod/Part/Part.so: undefined symbol: _ZN7gp_Trsf9SetValuesEdddddddddddd // Why is this happening?
does this problem also happen with the console of freecad?
Yes. Also an Import Error happens when I try to import ‘Mesh’! Actually this happens when I manually build the FreeCAD using the source, But when I added the PPA and installed FreeCAD via the console on ubuntu works fine!(Both Part and Mesh).
Is it means my manual build contains errors? but I get a successfully build log!
there is definitly something wring with yiur build. Please add a new thread in the install/compile subforum and add some more Details about your Platform and build process.
just had a look at this again…
to start freecad from jupyter-notebook you have to open a new python2 notebook and run this code. there is no need for a jupyter kernel…
This also works with jupyter-qtconsole and jupyter-console. But there are many different versions of jupyter. so there are maybe some problems with some versions. But I have the feeling with latest jupyter version this gets more stable.