[ Fixed ] [ Bug ] Error when placing parts_library window with Arch_Window: gui_snapper.py issue?

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
Roy_043
Veteran
Posts: 8409
Joined: Thu Dec 27, 2018 12:28 pm

[ Fixed ] [ Bug ] Error when placing parts_library window with Arch_Window: gui_snapper.py issue?

Post by Roy_043 »

The doors and windows in parts_library can now be inserted with the Arch_Window command (see here).

But there is an error if you do so in V0.19:

Code: Select all

<class 'SyntaxError'>
Traceback (most recent call last):
  File "D:\BKG_Tmp\FreeCAD_0.19_Last\Mod\Draft\draftguitools\gui_snapper.py", line 1366, in click
    accept()
  File "D:\BKG_Tmp\FreeCAD_0.19_Last\Mod\Draft\draftguitools\gui_snapper.py", line 1380, in accept
    callback(self.pt, obj)
  File "D:\BKG_Tmp\FreeCAD_0.19_Last\Mod\Arch\ArchWindow.py", line 683, in getPoint
    FreeCADGui.doCommand("FreeCADGui.ActiveDocument.mergeProject('"+path+"')")
  File "<string>", line 1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Version:

Code: Select all

OS: Windows 8.1 (6.3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.20839 (Git)
Build type: Release
Branch: master
Hash: 09005766f10539dfe32314c33c2cd3efe9141d0b
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Dutch/Netherlands (nl_NL)
Last edited by Roy_043 on Sun May 31, 2020 4:11 pm, edited 1 time in total.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: [ Bug ] Error when placing parts_library window with Arch_Window: gui_snapper.py issue?

Post by carlopav »

IMHO it's not an error of the snapper.
The _CommandWindow ( the gui command window) sets up a Snapper getPoint callback.
When Snapper gets a clicked point by the user if forwards it to the _CommandWindow.getPoint method.
This method of the _CommandWindow object crash at line 685:

Code: Select all

FreeCADGui.doCommand("FreeCADGui.ActiveDocument.mergeProject('"+path+"')")
No idea why this happens...
follow my experiments on BIM modelling for architecture design
User avatar
Roy_043
Veteran
Posts: 8409
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Bug ] Error when placing parts_library window with Arch_Window: gui_snapper.py issue?

Post by Roy_043 »

Retesting this today I noticed that the parts_library path stored in user.cfg contained single backslashes:

Code: Select all

      <FCParamGroup Name="parts_library">
        <FCText Name="destination">C:\Users\UserName\AppData\Roaming\FreeCAD\Mod\parts_library<\FCText>
      <\FCParamGroup>
This is the cause of the problem. Changing them to forward slashes (as used by all the other stored paths) fixes the problem.

Don't know how I ended up with this faulty path.
User avatar
yorik
Founder
Posts: 13630
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: [ Fixed ] [ Bug ] Error when placing parts_library window with Arch_Window: gui_snapper.py issue?

Post by yorik »

That's really strange... There are two places that store that path I think:
https://github.com/yorikvanhavre/BIM_Wo ... ary.py#L49
https://github.com/FreeCAD/FreeCAD-libr ... CMacro#L94

I don't really know of other places that store full paths in preferences... Maybe we should do something there, like escape (\\) the backslashes?
User avatar
Roy_043
Veteran
Posts: 8409
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Fixed ] [ Bug ] Error when placing parts_library window with Arch_Window: gui_snapper.py issue?

Post by Roy_043 »

Minor related issue:
On the Windows OS paths reported to the user can contain a mix of forward slashes (first part of the path) and backslashes.
Example:
C:/Users/<UserName>/AppData/Roaming/FreeCAD/Macro\fpo\box\box.py(49)<class 'TypeError'>: PyCXX: Error creating object of type class Py::SeqBase<class Py::Object> from None
User avatar
yorik
Founder
Posts: 13630
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: [ Fixed ] [ Bug ] Error when placing parts_library window with Arch_Window: gui_snapper.py issue?

Post by yorik »

In any case if storing paths with forward slashes works even on windows, then we can just do things that way. I'll fix the two above locations
jgalak
Posts: 5
Joined: Mon Aug 20, 2018 7:02 pm

Re: [ Fixed ] [ Bug ] Error when placing parts_library window with Arch_Window: gui_snapper.py issue?

Post by jgalak »

Just did a fresh install of Freecad 0.19, installed Parts Library, got the exact same error. user.cfg had the path with some single backslashes and some double backslashes. Changed to single forward slashes, error went away. So problem appears to not be fixed.

For reference:
OS: Windows 10 Version 2004
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24267 +99 (Git)
Build type: Release
Branch: Branch_0.19.3
Hash: 6530e364184ce05ccff39501e175cf2237e6ee4b
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.3
Locale: English/United States (en_US)
User avatar
Roy_043
Veteran
Posts: 8409
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Fixed ] [ Bug ] Error when placing parts_library window with Arch_Window: gui_snapper.py issue?

Post by Roy_043 »

When you reinstall FreeCAD your 'old' user.cfg file, which may have already contained the parts_library setting, will still be used. If you restart FreeCAD after renaming user.cfg and run the PartsLibrary.FCMacro macro, you will be prompted to select a path and that path is stored with forward slashes. So I think this is in fact fixed.
Post Reply