Porting to python3

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
yorik
Site Admin
Posts: 11547
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Porting to python3

Postby yorik » Wed Jan 23, 2019 12:53 pm

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

Re: Porting to python3

Postby Chris_G » 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
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
Posts: 709
Joined: Sat Apr 19, 2014 6:23 am
Contact:

Re: Porting to python3

Postby bitacovir » Wed Jan 23, 2019 4:50 pm

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)

My Blog
Mini Airflow Tunnel Project
User avatar
yorik
Site Admin
Posts: 11547
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Porting to python3

Postby yorik » Thu Jan 24, 2019 1:24 pm

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: 664
Joined: Sat Aug 13, 2016 10:06 am
Contact:

Re: Porting to python3

Postby reox » Sat Jan 26, 2019 5:41 pm

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?
looo
Posts: 2894
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Tue Feb 05, 2019 5:45 pm

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.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
looo
Posts: 2894
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » 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
please help with my conda-packaging efforts: https://liberapay.com/looooo/
looo
Posts: 2894
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Wed Feb 06, 2019 9:52 am

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.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
wmayer
Site Admin
Posts: 14869
Joined: Thu Feb 19, 2009 10:32 am

Re: Porting to python3

Postby wmayer » 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
looo
Posts: 2894
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Wed Feb 13, 2019 7:31 am

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)
please help with my conda-packaging efforts: https://liberapay.com/looooo/