Porting to python3

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Porting to python3

Post by yorik »

I can't reproduce that error either... Do you have the BIM WB installed twice?
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Porting to python3

Post by Chris_G »

I think this is related to Python 3, ActiveView doesn't display the list of available properties and methods in the python console
when typing the dot :

Code: Select all

FreeCADGui.ActiveDocument.ActiveView

Code: Select all

>>> FreeCADGui.ActiveDocument.ActiveView.__dir__()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: __dir__

Code: Select all

OS: Ubuntu 18.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15548 (Git) AppImage
Build type: Release
Branch: master
Hash: df3853738ebe5f91e3768c47c5db5594809ffeb7
Python version: 3.6.7
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/France (fr_FR)
User avatar
bitacovir
Veteran
Posts: 1570
Joined: Sat Apr 19, 2014 6:23 am
Contact:

Re: Porting to python3

Post by bitacovir »

bitacovir wrote: Mon Jan 21, 2019 7:02 pm
yorik wrote: Mon Jan 21, 2019 12:36 pm Fasteners works OK for me with python3... Can you try reinstalling it?
Yes. I reinstalled it and now the message with error of Fasteners has gone.

But now I have this message:

Code: Select all

During initialization the error "'BIMWorkbench' already exists." occurred in C:\Users\Rafael\AppData\Roaming\FreeCAD\Mod\BIM.bak\InitGui.py
Please look into the log file for further informatio
n
Fixed.
I manually deleted all BIM Folders in AppData folder and reinstalled them via Addon Manager. No more messages about BIMWorkbench.
::bitacovir::
==================
One must be absolutely modern.
Arthur Rimbaud (A Season in Hell -1873)

Canal Youtube Grupo Telegram de FreeCAD Español

My personal web site
My GitHub repository
Mini Airflow Tunnel Project
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Porting to python3

Post by yorik »

Chris_G wrote: Wed Jan 23, 2019 4:40 pm I think this is related to Python 3, ActiveView doesn't display the list of available properties and methods in the python console
Yes I saw that too but couldn't nail down exactly what's happening. But it is only the rendering of the contents to the console, for ex.

Code: Select all

FreeCAD.ActiveDocument.ActiveView.getSceneGraph()
still works
reox
Posts: 929
Joined: Sat Aug 13, 2016 10:06 am
Contact:

Re: Porting to python3

Post by reox »

Just a general question: I build freecad from master with qt5 and py3 but it is unusable. Basically no geometry is shown and it can not made visible:

Code: Select all

Traceback (most recent call last):
  File "<string>", line 1, in <module>
<class 'AttributeError'>: 'Gui.ViewProviderDocumentObject' object has no attribute 'Visibility'
Are such errors and behaviour to be expected when building with py3 or should it work but my build configuration is wrong?
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Post by looo »

I think this is related to Python 3, ActiveView doesn't display the list of available properties and methods in the python console
Once we have finally moved to python3 we have to work on auto-completion anyway:
https://forum.freecadweb.org/viewtopic. ... 10#p206336

I have no idea why it is not working.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Post by looo »

Maybe a hint from pycxx [1]:
Do not forget to add the call range::init_type() to some module's init function. You will want a method in some module that can create range objects, too.
searching for "View3DInventorViewerPy::init_type()" seems to give only one occurrence. So this is never called.

[1] http://cxx.sourceforge.net/PyCXX-Python ... nsion_type
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Post by looo »

btw: There are also crashes because of the way how freecad tries to autocomplete:

Code: Select all

Program received signal SIGSEGV, Segmentation fault.
#0  /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20) [0x7f0c40663f20]
#1  0x7f0c42b36168 in Gui::CallTipsList::extractTipsFromObject(Py::Object&, Py::List&, QMap<QString, Gui::CallTip>&) const from /home/lo/conda/envs/freecad_gcc7/bin/../lib/libFreeCADGui.so+0x2d8
#2  0x7f0c42b38da6 in Gui::CallTipsList::extractTips(QString const&) const from /home/lo/conda/envs/freecad_gcc7/bin/../lib/libFreeCADGui.so+0xb26
#3  0x7f0c42b3961b in Gui::CallTipsList::showTips(QString const&) from /home/lo/conda/envs/freecad_gcc7/bin/../lib/libFreeCADGui.so+0x20b
#4  0x7f0c42b48084 in Gui::PythonConsole::keyPressEvent(QKeyEvent*) from /home/lo/conda/envs/freecad_gcc7/bin/../lib/libFreeCADGui.so+0x554
#5  0x7f0c4125af77 in QWidget::event(QEvent*) from /home/lo/conda/envs/freecad_gcc7/bin/../lib/libQt5Widgets.so.5+0x7e7
#6  0x7f0c413334ae in QFrame::event(QEvent*) from /home/lo/conda/envs/freecad_gcc7/bin/../lib/libQt5Widgets.so.5+0x1e

I guess this feature has to be aligned with the standard python way to do this. Maybe the easiest way is to rewrite the FreeCAD-console in python. There are some examples available: eg.: ipython-qt-console

btw.: auto-completing also doesn't work for activeView in jupyter-qt-console.
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Porting to python3

Post by wmayer »

looo wrote: Tue Feb 05, 2019 6:36 pm Maybe a hint from pycxx [1]:
Do not forget to add the call range::init_type() to some module's init function. You will want a method in some module that can create range objects, too.
searching for "View3DInventorViewerPy::init_type()" seems to give only one occurrence. So this is never called.

[1] http://cxx.sourceforge.net/PyCXX-Python ... nsion_type
https://github.com/FreeCAD/FreeCAD/blob ... n.cpp#L425
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Post by looo »

wmayer wrote: Tue Feb 12, 2019 2:36 pm
looo wrote: Tue Feb 05, 2019 6:36 pm Maybe a hint from pycxx [1]:
Do not forget to add the call range::init_type() to some module's init function. You will want a method in some module that can create range objects, too.
searching for "View3DInventorViewerPy::init_type()" seems to give only one occurrence. So this is never called.

[1] http://cxx.sourceforge.net/PyCXX-Python ... nsion_type
https://github.com/FreeCAD/FreeCAD/blob ... n.cpp#L425

I see, thanks. Any ideas how to debug this behavior? (missing auto-completion)
Post Reply