?BUG 0.19 opening file that includes BIM building object results in 'NameError: name 'FreeCADGui' is not defined'

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
duncandoo
Posts: 5
Joined: Mon Jan 27, 2020 7:22 pm

?BUG 0.19 opening file that includes BIM building object results in 'NameError: name 'FreeCADGui' is not defined'

Postby duncandoo » Thu Jun 18, 2020 6:14 pm

To recreate:
1. open FreeCAD, open a new file, switch to BIM workbench
2.create a building object, save file and close
3. reopen test file
4. error appears.

I have made the error go away by adding import FreeCADGui to either line 28 or 131 of BimViews.py. I'm not sure which is preferable, whether this might have some undesirable effect elsewhere, or whether the reference to FreeCADGui on line 152 is necessary at all?

Any advice on best solution gratefully received.

Version:
OS: macOS High Sierra (10.13)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.21514 (Git)
Build type: Release
Branch: master
Hash: 89ddab33f692a9bd739171689f9ab0eb58d64b35
Python version: 3.8.2
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: C/Default (C)

Console display:

Python 3.8.3 | packaged by conda-forge | (default, Jun 1 2020, 17:26:49)
[Clang 9.0.1 ] on darwin
Type 'help', 'copyright', 'credits' or 'license' for more information.
>>> Gui.runCommand('Std_Workbench',20)
>>> Gui.runCommand('Std_ViewStatusBar',1)
>>> MRU="0"
>>> exec(open('/Applications/FreeCAD.app/Contents/Resources/share/Mod/Start/StartPage/LoadMRU.py').read())
>>> FreeCAD.openDocument('/Users/duncan/test.FCStd')
>>> # App.setActiveDocument("test")
>>> # App.ActiveDocument=App.getDocument("test")
>>> # Gui.ActiveDocument=Gui.getDocument("test")
>>> Gui.runCommand('Std_OrthographicCamera',1)
>>> Gui.runCommand('Std_About',0)
>>>


Traceback (most recent call last):
File "/Users/duncan/Library/Preferences/FreeCAD/Mod/BIM/BimViews.py", line 153, in update
if obj in FreeCADGui.Selection.getSelection():
NameError: name 'FreeCADGui' is not defined
TheMarkster
Posts: 2057
Joined: Thu Apr 05, 2018 1:53 am

Re: ?BUG 0.19 opening file that includes BIM building object results in 'NameError: name 'FreeCADGui' is not defined'

Postby TheMarkster » Thu Jun 18, 2020 8:47 pm

Open that file and change the line at the top from:

Code: Select all

import FreeCAD
to

Code: Select all

import FreeCAD, FreeCADGui
and see if that fixes it. (You will need to restart FreeCAD to test it.)
My FreeCAD video series on youtube: https://www.youtube.com/c/mwganson
carlopav
Posts: 1613
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: ?BUG 0.19 opening file that includes BIM building object results in 'NameError: name 'FreeCADGui' is not defined'

Postby carlopav » Thu Jun 18, 2020 8:55 pm

Ping myself to remember to fix it!
follow my experiments on BIM modelling for architecture design
vocx
Posts: 5206
Joined: Thu Oct 18, 2018 9:18 pm

Re: ?BUG 0.19 opening file that includes BIM building object results in 'NameError: name 'FreeCADGui' is not defined'

Postby vocx » Thu Jun 18, 2020 9:00 pm

duncandoo wrote:
Thu Jun 18, 2020 6:14 pm
...
I have made the error go away by adding import FreeCADGui ...
Importing FreeCADGui is indeed the solution, as TheMarkster says.

However, please notice that BIM is an external workbench and it is constantly in development, so you should update BIM regularly to make sure you are using the latest version. It's possible this error will be corrected quickly when the developer notices it.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.