[Solved] Tool Library Error

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)

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?

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

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.

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

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

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

OK, here is another observation.
library.jpg
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

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

Success:

In User.cfg, I changed the item , which was pointing to the roaming directory, to a folder in my documents directory. 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

That’s a known issue, we’re working on a fix for that.

OK, Good. I could not find info on it, perhaps dis not search proper terms. At least it will get resolved.

Chuck

Hi, I’m Engin from Turkey.

I had the same issue. Thank you for solution.
First of all, my English is not good, sorry. I use sometimes translate.
Something caught my attention.
Before the solution; when I open path tool library window, the window title have a path for library on roaming directory.
After I reading your solution, I closed the FreeCAD. I opened the user.cfg file in roaming directory with Notepad ++. I cleaned the roaming directory and I changed to “C:\Program Files\FreeCAD_0.19Beta\Mod\Path\Tools\Library”.
After this step, I opened the FreeCad and everything is working properly. I opened the tool library window and I seen tool bits.
I think program can not have access for roaming directory path.

Thanks.
Engin.

“”

Where exactly is this supposed to be in the user.cfg? Because my user.cfg doesn’t have that. Talk to me like I’m a child editing a file for the first time, considering today is the first time I have had to do that with FreeCAD. Also, I have a library.fctl file. It got erased by FreeCAD and it now has no entries, so I cannot edit it. There’s nothing there to edit, so I don’t know what an entry is supposed to look like.

This tutorial isn’t helping because none of it works.
https://www.youtube.com/watch?v=9FfFwVrZdlk

The “Shape” folder is empty. The “bit” folder is not, however none of the premade examples can be saved in the gui.

Using current version appimage on Fedora.

EDIT:

After deleting EVERYTHING, and starting over, I’ve managed to get to the point where I can add new tools by opening up the “Bit” folder, selecting one, and saving-as something else, editing values, and then adding it to the job in FreeCAD.

im having the same issue.. on a fresh install of Ubuntu, fresh install of freecad .20

the thing is.. i have NO IDEA what is going on this thread.. can some one please post a simple walk through.. i barely have time to explore the program let alone comprehend how to fix a buried file with codes i have no idea what they mean.. can some one explain whats going on to me..

i have never been so frustrated with a program in my whole life.