[Solved] Tool Library Error

Here's the place for discussion related to CAM/CNC and the development of the Path module.
ceandraka
Posts: 24
Joined: Sun Dec 27, 2020 11:24 pm

[Solved] Tool Library Error

Postby ceandraka » Tue Jan 12, 2021 11:21 pm

When trying to utilize the new tool library, I run into an error, both when modifying a tool, and when trying to close the library. This results in no tools in the library the next time I open the library.

When closing the library, I get the following error:

16:06:37 Traceback (most recent call last):
16:06:37 File "C:\Program Files\FreeCAD 0.19Beta\Mod\Path\PathScripts\PathToolBitLibraryGui.py", line 611, in libraryOk
16:06:37 self.librarySave()
16:06:37 File "C:\Program Files\FreeCAD 0.19Beta\Mod\Path\PathScripts\PathToolBitLibraryGui.py", line 607, in librarySave
16:06:37 with open(self.path, 'w') as fp:
16:06:37 TypeError: expected str, bytes or os.PathLike object, not NoneType

This prevents closing the library, the only way to get it to close is the X in the upper right corner, but this fails to save the library.

Similarly, if I try to create a new bit, it makes a new bit based on an existing shape. I then edit by double-clicking on the bit, adjust the parameters to the new bit desired size, then hit OK and I get this error:

16:12:42 Traceback (most recent call last):
16:12:42 File "C:\Program Files\FreeCAD 0.19Beta\Mod\Path\PathScripts\PathToolBitLibraryGui.py", line 517, in accept
16:12:42 self.librarySave()
16:12:42 File "C:\Program Files\FreeCAD 0.19Beta\Mod\Path\PathScripts\PathToolBitLibraryGui.py", line 607, in librarySave
16:12:42 with open(self.path, 'w') as fp:
16:12:42 TypeError: expected str, bytes or os.PathLike object, not NoneType

I can cancel out of the tool parameters, and if I double-click the tool again I see it is updated. But, again, if I close the library it is lost.

It appears to me these errors are all to do with the library. I have tried opening existing libraries (none found), and creating new ones.

Thanks
Chuck

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.23578 (Git)
Build type: Release
Branch: master
Hash: 50c3cbf00579dc4941ca743c25720d016b0453ce
Python version: 3.8.6
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)
Last edited by ceandraka on Thu Jan 14, 2021 2:10 am, edited 2 times in total.
User avatar
sliptonic
Posts: 2083
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Tool Library Error

Postby sliptonic » Wed Jan 13, 2021 12:56 am

I'm not sure. Are you trying to write to a network drive? Do you have write access to working location?

You might try setting the location to a local directory and trying again. Please let us know what you find?
ceandraka
Posts: 24
Joined: Sun Dec 27, 2020 11:24 pm

Re: Tool Library Error

Postby ceandraka » Wed Jan 13, 2021 1:48 am

It is on a local drive. I have tried using the default location (C:\Users\ceand\AppData\Roaming\FreeCAD\Macro), a path in the install location (C:\Program Files\FreeCAD 0.19Beta\Mod\Path\Tools\Library), and a path in my local documents directory (C:\Users\ceand\Local Documents\CNC Router).

If I try making a new library (second choice on left side of window), I get the following error:

18:34:28 Traceback (most recent call last):
18:34:28 File "C:\Program Files\FreeCAD 0.19Beta\Mod\Path\PathScripts\PathToolBitLibraryGui.py", line 499, in libraryPath
18:34:28 PathPreferences.setLastPathToolLibrary(path)
18:34:28 File "C:\Program Files\FreeCAD 0.19Beta\Mod\Path\PathScripts\PathPreferences.py", line 319, in setLastPathToolLibrary
18:34:28 if os.path.split(curLib)[0] != path:
18:34:28 File "C:\Program Files\FreeCAD 0.19Beta\bin\lib\ntpath.py", line 185, in split
18:34:28 p = os.fspath(p)
18:34:28 TypeError: expected str, bytes or os.PathLike object, not NoneType

This is regardless of the location selected.

This looks similar to the other errors reported in the first post.

It does not appear to be a permissions issue, at least not for the library path. Could be permissions for something else?

I also note that if I try to OPEN a library in the default location (the Roaming directory), it finds no files of the right type there. However, if I try CREATING a new library, in the default location, there are three libraries there (files that end in fctl). These are all empty libraries that were created, but when tools were added they errored out.

Actually, one of the libraries has the following content:

{
"tools": [
{
"nr": 1,
"path": "/013in_Drill.fctb"
},
{
"nr": 2,
"path": "/013in_endmill.fctb"
}
],
"version": 1
}

I am not sure when that occurred. The other two have:

{
"tools": [],
"version": 1
}

But none of these are seen if I try to open a library (top choice). Perhaps because it is looking for a default name (it says select folder, not select file). I think the three that I found were created with the third menu item, "Save the selected library with a new name"

Thanks
Chuck
onekk
Posts: 464
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Tool Library Error

Postby onekk » Wed Jan 13, 2021 7:43 am

What version of FreeCAD are you using?

Have you reused a FreeCAD user directory from an old version?

I have recently made a tool library using the internal tool library edit tools, and then modified the toolbit data by hand and i have had no problem.


But in 0.19 recently the way to manage tools is changed so an old file tree maybe is the source of problem.

Maybe renaming the original FreeCAD user dir and recreate a new one, will resolve some problems, (eventually you could copy the other user file in a second time to find maybe the file that caused the wrong behaviour.)

Better to put the FreeCAD about information in the next message to facilitate to pinpoint the problem by some developer.

Regards

Carlo D.
ceandraka
Posts: 24
Joined: Sun Dec 27, 2020 11:24 pm

Re: Tool Library Error

Postby ceandraka » Wed Jan 13, 2021 4:36 pm

Carlo:

Please see my OP up top. It has the FC About info. I am using the latest (as of yesterday) FC development version, as suggested for path-related issues.

FC 19 is installed in a clean directory structure in the Program Files directory of Windows. When I updated yesterday, I wiped the FC 19 structure completely before unzipping the new version. I still have FC 18 on the machine in a different directory of the Program Files structure.

What is the "user directory"? I can try renaming that. Is that the Roaming structure I pointed out, or something in the Program Files section?

As noted, I have tried opening/creating libraries in a number of places to no avail. I will gladly try eliminating the "old file tree" if I can please get a little guidance.

Thanks
Chuck
GeneFC
Posts: 1804
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Tool Library Error

Postby GeneFC » Wed Jan 13, 2021 5:20 pm

The tool bits have a unique file extension, fctb.

You might try an exhaustive search to find any places on your disk where that file extension exists. That could give you a lead to where the outdated or incorrect library files are located.

Gene
ceandraka
Posts: 24
Joined: Sun Dec 27, 2020 11:24 pm

Re: Tool Library Error

Postby ceandraka » Wed Jan 13, 2021 7:30 pm

Thank you for your patience in this.

I agree it is probably something specific to my machine, since this is not a widely reported problem.

I did a search for fctb on my hard drive, and sorted by location. The ONLY locations that come up are:

C:\Program Files\FreeCAD 0.19Beta\Mod\Path\Tools\Bit
recent
recent items

The recent and recent items are simply shortcuts.

I then searched for fctl to find libraries. They were found in the locations that I already discussed above, all having to do with v19 installation:

C:\Program Files\FreeCAD 0.19Beta\Mod\Path\Tools\Library
C:\Users\ceand\AppData\Roaming\FreeCAD\Macro
C:\Users\ceand\Local Documents\CNC Router

I deleted the libraries in these locations, restarted FC, and had the same results. I open the tool library, it is blank. I "add existing" and select one of the fctb files in the folder. I then hit "close" and get the error.

Willing to generate/review other logs, if anything beyond the error (Report View) window is needed.

I started looking at the code referenced in the error, but I am not up to speed on python, so it quickly got over my head.

Thanks again
Chuck
ceandraka
Posts: 24
Joined: Sun Dec 27, 2020 11:24 pm

Re: Tool Library Error

Postby ceandraka » Wed Jan 13, 2021 8:14 pm

OK, here is another observation.
library.jpg
library.jpg (34.83 KiB) Viewed 221 times
My library window does not show any libraries in the left pane, unlike that shown at https://wiki.freecadweb.org/Path_ToolBitLibraryOpen. I can hit the second button, Add New Tool Table, and it does indeed create a new library on the disk. However, it does not add it to the list in the window. Thus, when I save or close, there is nothing in the list, therefore giving the error when it tries to update the "current" library.

I have also verified that the preference to use legacy libraries is not checked.

Thanks again
Chuck
ceandraka
Posts: 24
Joined: Sun Dec 27, 2020 11:24 pm

Re: Tool Library Error

Postby ceandraka » Wed Jan 13, 2021 8:40 pm

I tried deleting the user.cfg file in C:\Users\ceand\AppData\Roaming\FreeCAD and restarting FC19.

I opened my existing file, then did path/Toolbit Library Editor. A pop-up window says "Toolbit Working Directory not set up. Do that now?", and I answer "yes". It opens a file dialog and labelled "Choose a writeable location for your toolbits". I tried several, including in my local documents. An error is shown:

13:37:42 Running the Python command 'Path_ToolBitLibraryOpen' failed:
Traceback (most recent call last):
File "C:\Program Files\FreeCAD 0.19Beta\Mod\Path\PathScripts\PathToolBitLibraryCmd.py", line 78, in Activated
library = PathToolBitLibraryGui.ToolBitLibrary()
File "C:\Program Files\FreeCAD 0.19Beta\Mod\Path\PathScripts\PathToolBitLibraryGui.py", line 364, in __init__
if not self.checkWorkingDir():
File "C:\Program Files\FreeCAD 0.19Beta\Mod\Path\PathScripts\PathToolBitLibraryGui.py", line 402, in checkWorkingDir
PathPreferences.setLastPathToolLibrary("{}/Library".format(workingdir))
File "C:\Program Files\FreeCAD 0.19Beta\Mod\Path\PathScripts\PathPreferences.py", line 319, in setLastPathToolLibrary
if os.path.split(curLib)[0] != path:
File "C:\Program Files\FreeCAD 0.19Beta\bin\lib\ntpath.py", line 185, in split
p = os.fspath(p)

expected str, bytes or os.PathLike object, not NoneType

So, I restored my user.cfg file and await further insights.

Thanks
Chuck
ceandraka
Posts: 24
Joined: Sun Dec 27, 2020 11:24 pm

Re: Tool Library Error

Postby ceandraka » Wed Jan 13, 2021 9:02 pm

Success:

In User.cfg, I changed the item <FCText Name="LastPathToolLibrary">, which was pointing to the roaming directory, to a folder in my documents directory. <FCText Name="LastFileToolLibrary"> was blank, and I left it so. I put a default (empty) library in there. I then restarted FC19, and tried opening the library. It said it needed to be set up, but this time it did set it up.

So,

1. Somehow the default, or prior, location for the library was pointing to a place FC could not deal with (C:\Users\ceand\AppData\Roaming\FreeCAD\Macro)
2. Attempting to change this by opening a new location in FC would throw an error
3. Deleting user.cfg and allowing it to be rebuilt also ended in error

The only way to fix was through manual edit of the user.cfg file.

I suspect that some parameters in the user.cfg file were reused form the legacy library, and pointed to areas without permission. I don't know. But now it works.

Chuck