Assembly4: XLink absolute filepath problem

Discussion about the development of the Assembly workbench.
realthunder
Posts: 1810
Joined: Tue Jan 03, 2017 10:55 am

Re: Assembly4: XLink absolute filepath problem

Postby realthunder » Wed Aug 26, 2020 9:02 am

Zolko wrote:
Wed Aug 26, 2020 8:56 am
And what happens if we load the same document through different symlink-path into the assembly ?
It will be treated as different document up on loading, and will overwrite the other up on saving. As I mentioned in the code comment, we'll just assume the user is aware of this. The user can actually load the files, and then change the symlink in the file system, and do some magic stuff upon saving, which actually makes sense.
Try Assembly3 (latest version 0.11) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
project4
Posts: 192
Joined: Fri Jul 12, 2013 12:53 pm

Re: Assembly4: XLink absolute filepath problem

Postby project4 » Wed Aug 26, 2020 9:21 am

This is a very wrong approach!

The symbolic link is use to hide all the physical hierarchy of driver, while leaving the logical path the same on all the machines.
I have "/home/username/Workspace" the same on all the machines, while Workspace is a symbolic link to the drive.
On some machines it links to local SDD, on others to local RAID and on another to NFS mount of the RAID located on another machine.
But on all, the "/home/username/Workspace" stays the same.

Saving the absolute path will kill any way to share the work between the people as well.
Some have it saved in C:, others in D:.
realthunder
Posts: 1810
Joined: Tue Jan 03, 2017 10:55 am

Re: Assembly4: XLink absolute filepath problem

Postby realthunder » Wed Aug 26, 2020 9:26 am

project4 wrote:
Wed Aug 26, 2020 9:21 am
Saving the absolute path will kill any way to share the work between the people as well.
huh? But I specifically said that the absolute path is NOT used for saving. It is used internally for looking up loaded documents.
Try Assembly3 (latest version 0.11) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
project4
Posts: 192
Joined: Fri Jul 12, 2013 12:53 pm

Re: Assembly4: XLink absolute filepath problem

Postby project4 » Wed Aug 26, 2020 9:34 am

Could be that I didn't understand that from your last post.

Is there a change in the code that is used to set files path for saving?
The problem I see is that the file name is set to the physical location instead of the logical one.
realthunder
Posts: 1810
Joined: Tue Jan 03, 2017 10:55 am

Re: Assembly4: XLink absolute filepath problem

Postby realthunder » Wed Aug 26, 2020 9:43 am

project4 wrote:
Wed Aug 26, 2020 9:34 am
Could be that I didn't understand that from your last post.

Is there a change in the code that is used to set files path for saving?
The problem I see is that the file name is set to the physical location instead of the logical one.
No change in saving, but change in loading. Before this PR, the linked file is loaded using the resolved so called 'canonical' path. When you save the linking file, the link path is set as the relative path calculated using the resolved canonical path. After the PR, the linked file is loaded without resolving the path.
Try Assembly3 (latest version 0.11) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
project4
Posts: 192
Joined: Fri Jul 12, 2013 12:53 pm

Re: Assembly4: XLink absolute filepath problem

Postby project4 » Wed Aug 26, 2020 9:55 am

I'm not familiar with the code, but have a feeling there is an additional problem somewhere else.
Will wait for the merge to test.

The load might not resolve the path for the check now, but I think there is still a code that sets the linked filename with a wrong path (physical instead of logical).
That code might still run on save or other triggers.
User avatar
Zolko
Posts: 1101
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly4: XLink absolute filepath problem

Postby Zolko » Wed Aug 26, 2020 10:00 am

realthunder wrote:
Wed Aug 26, 2020 9:02 am
Zolko wrote:
Wed Aug 26, 2020 8:56 am
And what happens if we load the same document through different symlink-path into the assembly ?
It will be treated as different document up on loading, and will overwrite the other up on saving. As I mentioned in the code comment, we'll just assume the user is aware of this.
you mean that we could have 2 windows open on the same file without the user being aware of it ? Are we sure this is really what we want ?
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
realthunder
Posts: 1810
Joined: Tue Jan 03, 2017 10:55 am

Re: Assembly4: XLink absolute filepath problem

Postby realthunder » Wed Aug 26, 2020 10:11 am

Zolko wrote:
Wed Aug 26, 2020 10:00 am
you mean that we could have 2 windows open on the same file without the user being aware of it ? Are we sure this is really what we want ?
Maybe add some parameter to control whether to allow loading the same physical file from different logical path. I'll think about it.
Try Assembly3 (latest version 0.11) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
Zolko
Posts: 1101
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly4: XLink absolute filepath problem

Postby Zolko » Wed Aug 26, 2020 10:21 am

realthunder wrote:
Wed Aug 26, 2020 10:11 am
Zolko wrote:
Wed Aug 26, 2020 10:00 am
you mean that we could have 2 windows open on the same file without the user being aware of it ? Are we sure this is really what we want ?
Maybe add some parameter to control whether to allow loading the same physical file from different logical path. I'll think about it.
I think that this is a real and known issue in any CAD system, and they deal with it in different ways (CATIA, NX, SolidWorks...). The main question is the use of parts libraries, that will reside outside of the assembly directory, and in different locations, relative and absolute, on different systems. At some point I thought about using symlinks, but this appears now sub-optimal. The best solution I have seen is that of NX, where you can specify search paths and the priority between them.

May-be a solution would be to forbid a link to climb the directory hierarchy (no /../), and instead allow to define library paths (like Lib_1 = /home/user/CAD/Parts) and then link a part from that library (like Lib_1/Supplier_12/Part_1234). The library path would be set per user of course. If Part_1234 appears several times in the assembly at different levels, all links always point to the same file.

What do you think of that ?
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
realthunder
Posts: 1810
Joined: Tue Jan 03, 2017 10:55 am

Re: Assembly4: XLink absolute filepath problem

Postby realthunder » Wed Aug 26, 2020 11:24 am

Zolko wrote:
Wed Aug 26, 2020 10:21 am
May-be a solution would be to forbid a link to climb the directory hierarchy (no /../), and instead allow to define library paths (like Lib_1 = /home/user/CAD/Parts) and then link a part from that library (like Lib_1/Supplier_12/Part_1234). The library path would be set per user of course. If Part_1234 appears several times in the assembly at different levels, all links always point to the same file.

What do you think of that ?
I think this solution is too specific to be included in the core. The way I see it, allowing loading the same physical file from different location does expose danger of accidental overwrite. So I'll add a parameter/preference option that by default disables this and only load from the first logical location, and output some warning to the console notifying the user. The user can on the other hand enable this at his own risk.
Try Assembly3 (latest version 0.11) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal