Relative Paths for Toolbits

Here's the place for discussion related to CAM/CNC and the development of the Path module.
User avatar
dubstar-04
Posts: 639
Joined: Mon Mar 04, 2013 8:41 pm
Location: Chester, UK
Contact:

Relative Paths for Toolbits

Postby dubstar-04 » Tue Apr 27, 2021 3:41 pm

Is it possible to store tool bits with relative paths?

I am using the default folder structure

- Bit
- Library
- Shape

The library and tools have the full path. This makes it impossible to share the tool libraries between different OS'.

Code: Select all

"shape": "C:/Users/daniel.wood/Documents/FreeCAD/Tools/Shape/bullnose.fcstd"

"path": "C:/Users/daniel.wood/Documents/FreeCAD/Tools\\Bit\\5mm_Endmill.fctb"

"path": "/media/Nextcloud/Dropbox/CAM/Tool-Tables/FreeCAD/Bit/Shellmill.fctb"

I have tried changing the toggle for the absolute paths and this doesn't seem to have any affect.
FreeCAD-Preferences.png
FreeCAD-Preferences.png (5.7 KiB) Viewed 316 times
Thanks,

Dan
User avatar
sliptonic
Posts: 2213
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Relative Paths for Toolbits

Postby sliptonic » Tue Apr 27, 2021 6:12 pm

Relative paths work fine but simply changing the default will not cause the libraries and bit files to be rewritten. You would need to change something in the library so it's re-written. Likewise the bit files. At the point it is saved, the relative or absolute path is generated and written to the file.
User avatar
dubstar-04
Posts: 639
Joined: Mon Mar 04, 2013 8:41 pm
Location: Chester, UK
Contact:

Re: Relative Paths for Toolbits

Postby dubstar-04 » Tue Apr 27, 2021 8:17 pm

sliptonic wrote:
Tue Apr 27, 2021 6:12 pm
Relative paths work fine but simply changing the default will not cause the libraries and bit files to be rewritten. You would need to change something in the library so it's re-written. Likewise the bit files. At the point it is saved, the relative or absolute path is generated and written to the file.
Hi Brad,

Thanks for the reply. Do you have a workflow that results in the use of relative paths?

I have tried creating tool tables several times and they always end up using absolute paths in the tool library (.fctl).

Thanks,

Dan
User avatar
sliptonic
Posts: 2213
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Relative Paths for Toolbits

Postby sliptonic » Tue Apr 27, 2021 8:32 pm

ideally, start with relative paths and stay with relative paths.

If you already have absolute paths, it's easy to fix in the library:
1) change the preference to relative and restart FreeCAD.
2) open the dock.
3) change something. Add a tool, change a tool number, etc
4) close the dock. The library should now have relative paths to all the toolbits (not just the one changed).

This will only change the library. The individual toolbits will still have an absolute path to the shape file.
Presumably you can open each one in the editor, change something and save it. I haven't tested this directly but it should work.

It might be faster to open them in a text editor though.
User avatar
dubstar-04
Posts: 639
Joined: Mon Mar 04, 2013 8:41 pm
Location: Chester, UK
Contact:

Re: Relative Paths for Toolbits

Postby dubstar-04 » Tue Apr 27, 2021 9:02 pm

sliptonic wrote:
Tue Apr 27, 2021 8:32 pm
ideally, start with relative paths and stay with relative paths.

If you already have absolute paths, it's easy to fix in the library:
1) change the preference to relative and restart FreeCAD.
2) open the dock.
3) change something. Add a tool, change a tool number, etc
4) close the dock. The library should now have relative paths to all the toolbits (not just the one changed).

This will only change the library. The individual toolbits will still have an absolute path to the shape file.
Presumably you can open each one in the editor, change something and save it. I haven't tested this directly but it should work.

It might be faster to open them in a text editor though.

I've tried the suggestion thank you.

Its just not possible to end up with relative paths.

Steps:

1. Delete FreeCAD config
2. Create completely new tool library in an empty directory
3. Create a toolbit
4. check fctl and tctb

Code: Select all

{
  "tools": [
    {
      "nr": 1,
      "path": "/home/sandal/Documents/FreeCAD/Tools/Bit/endmill1.fctb"
    }
  ],
  "version": 1
}

Code: Select all

{
  "version": 2,
  "name": "endmill1",
  "shape": "/home/sandal/Documents/FreeCAD/Tools/Shape/endmill.fcstd",
  "parameter": {
    "Chipload": "0.00 mm",
    "CuttingEdgeHeight": "30.00 mm",
    "Diameter": "5.00 mm",
    "Flutes": "0",
    "Length": "50.00 mm",
    "Material": "HSS",
    "ShankDiameter": "3.00 mm"
  },
  "attribute": {}
}


OS: Ubuntu 20.10 (ubuntu:GNOME/ubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Branch: unknown
Hash: b2b6ffb89097c7e18ea22c7727a4adb41fb3de31
Python version: 3.8.6
Qt version: 5.14.2
Coin version: 4.0.0
OCC version: 7.5.1
Locale: English/United Kingdom (en_GB)
User avatar
dubstar-04
Posts: 639
Joined: Mon Mar 04, 2013 8:41 pm
Location: Chester, UK
Contact:

Re: Relative Paths for Toolbits

Postby dubstar-04 » Tue Apr 27, 2021 9:09 pm

The tool library and bits that FreeCAD generate by default have relative paths until a change is made, then all paths are converted to absolute.

Thanks,

Dan
User avatar
sliptonic
Posts: 2213
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Relative Paths for Toolbits

Postby sliptonic » Wed Apr 28, 2021 2:22 pm

Well....crap. You're right.

The resolution of a relative path is done here. It doesn't work.

This is going to require some work. Please open a ticket for this.
User avatar
dubstar-04
Posts: 639
Joined: Mon Mar 04, 2013 8:41 pm
Location: Chester, UK
Contact:

Re: Relative Paths for Toolbits

Postby dubstar-04 » Wed Apr 28, 2021 3:24 pm

sliptonic wrote:
Wed Apr 28, 2021 2:22 pm
Well....crap. You're right.

The resolution of a relative path is done here. It doesn't work.

This is going to require some work. Please open a ticket for this.
Thanks for confirming.

Ticket Here:

https://tracker.freecadweb.org/view.php?id=4647

Dan.
chrisb
Posts: 34269
Joined: Tue Mar 17, 2015 9:14 am

Re: Relative Paths for Toolbits

Postby chrisb » Wed Apr 28, 2021 6:08 pm

Would it help to use App.ActiveDocument.FileName and split the Path from it to get the path from the current document?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
sliptonic
Posts: 2213
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Relative Paths for Toolbits

Postby sliptonic » Wed Apr 28, 2021 7:33 pm

chrisb wrote:
Wed Apr 28, 2021 6:08 pm
Would it help to use App.ActiveDocument.FileName and split the Path from it to get the path from the current document?
Not really. The toolbit and shape locations aren't relative to the document location.
The toolbit location is relative to the toolbit library.
The tool shape location is relative to the toolbit file.

At least that's the concept. I really dislike this feature. I mean it's really nice when it works well and it's well-written and I don't see an alternative. But it has to anticipate a lot of assumptions made by users and therefore invariably gets 'messy'.