Assembly4: XLink absolute filepath problem

Discussion about the development of the Assembly workbench.
User avatar
Zolko
Posts: 1103
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly4: XLink absolute filepath problem

Postby Zolko » Mon Sep 07, 2020 8:25 am

realthunder wrote:
Fri Sep 04, 2020 11:52 pm
The main concern I have with absolute path is how to deal with the situation when the path no longer exist
Is rising an error an option ? And then let the user sort out the mess he created. That would be my preferred usage.
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 » Mon Sep 07, 2020 11:28 pm

Zolko wrote:
Mon Sep 07, 2020 8:25 am
realthunder wrote:
Fri Sep 04, 2020 11:52 pm
The main concern I have with absolute path is how to deal with the situation when the path no longer exist
Is rising an error an option ? And then let the user sort out the mess he created. That would be my preferred usage.
But it may also be someone else who unfortunately receives this type of files must suffer the consequences. The problem is that the broken links can exists in numerous places across multiple hierarchies. It will be nice to have some dialog to collect all the broken links and let user edit. But with this type of effort, I'd rather do it properly using library 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
User avatar
Zolko
Posts: 1103
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly4: XLink absolute filepath problem

Postby Zolko » Tue Sep 08, 2020 7:26 am

realthunder wrote:
Mon Sep 07, 2020 11:28 pm
But it may also be someone else who unfortunately receives this type of files must suffer the consequences.
That's a funny way to put it. The use-case for absolute paths is either for a unique designer working on his own computer, or a small team who decides to standardize on a single OS for all workstations, and decides to put all CAD project files in the same location on all workstations. In this case, absolute paths is simple to explain, setup, maintain and backup.

Code: Select all

sudo mkdir /home/CAD
sudo chown cadadmin:cadusers /home/CAD
sudo chmod 750 /home/CAD
su cadadmin 
mkdir /home/CAD/PartsLibrary
mkdir /home/CAD/Project_1
mkdir /home/CAD/Project_2
...

realthunder wrote:
Mon Sep 07, 2020 11:28 pm
I'd rather do it properly using library path.
that should be a long-term goal, but please consider that, even in this case, setting up a good working environment for many participants of a project using various OS and versions is a difficult task, and for some simple use-cases overkill.
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
michaelquigley
Posts: 19
Joined: Thu Oct 15, 2020 4:27 am

Re: Assembly4: XLink absolute filepath problem

Postby michaelquigley » Thu Oct 15, 2020 4:55 am

realthunder wrote:
Mon Sep 07, 2020 11:28 pm
But it may also be someone else who unfortunately receives this type of files must suffer the consequences. The problem is that the broken links can exists in numerous places across multiple hierarchies. It will be nice to have some dialog to collect all the broken links and let user edit. But with this type of effort, I'd rather do it properly using library path.
So, I've been working really hard to get converted over to FreeCAD (from Fusion 360) over the course of the last couple of weeks. I'm just about there. I use FreeCAD for furniture and motion control robotics design. I'm primarily using Part Design/Sketcher/Assembly 3/Path. I'm doing almost all of my manufacturing on a CNC router.

I ran into an issue tonight...

I made a document that contains an Assembly 3 assembly. I used links to pull in parts from several places on my filesystem. Everything is happy and working great. If I move the top-level assembly document to a different folder, every link in my document is broken. That's not a showstopper... I'd pretty much expect that.

But I can't figure out any way to FIX the links. I really wouldn't even mind manually editing the link paths and pointing them to where they should be... but for the life of me, I can't seem to find a way. It sounds to me like the relative path solution that's in place now is pretty sensible. Using a LIBRARY_PATH scheme might make that even slicker. But I'd really just like to be able to fix this stuff when I re-organize my parts tree.

p.s. I'm also a professional software developer, and I've been working on cross-platform C++ (and Qt) for a couple of decades now. I'm kind of up to my eyeballs in projects at the moment, but it's not outside the realm of possibility that I might be able to toss a PR or two at you folks if I find some targets of opportunity where I think I can help out.

p.p.s. I was able to unzip my Assembly.FCStd and dig through the Document.xml to fix all the paths, but I have not been able to re-zip to an FCStd file in such a way that FreeCAD is able to open it. I keep getting errors like this:

Code: Select all

00:53:17  Fatal Error at file D:/Projects/quigleycom/design/furniture/candleabra/Assembly.FCStd, line 1, char 1
00:53:17  Exception message is: 
00:53:17  invalid document structure
00:53:17  Traceback (most recent call last):
  File "<string>", line 1, in <module>
<class 'OSError'>: Error reading compression file: D:/Projects/quigleycom/design/furniture/candleabra/Assembly.FCStd
project4
Posts: 192
Joined: Fri Jul 12, 2013 12:53 pm

Re: Assembly4: XLink absolute filepath problem

Postby project4 » Thu Oct 15, 2020 7:02 am

Go go "Tools -> Project Utility"
That's the way to ZIP the changed files into the FTStd again
aapo
Posts: 213
Joined: Mon Oct 29, 2018 6:41 pm

Re: Assembly4: XLink absolute filepath problem

Postby aapo » Thu Oct 15, 2020 8:13 am

michaelquigley wrote:
Thu Oct 15, 2020 4:55 am
I made a document that contains an Assembly 3 assembly. I used links to pull in parts from several places on my filesystem. Everything is happy and working great. If I move the top-level assembly document to a different folder, every link in my document is broken. That's not a showstopper... I'd pretty much expect that.

But I can't figure out any way to FIX the links. I really wouldn't even mind manually editing the link paths and pointing them to where they should be... but for the life of me, I can't seem to find a way. It sounds to me like the relative path solution that's in place now is pretty sensible. Using a LIBRARY_PATH scheme might make that even slicker. But I'd really just like to be able to fix this stuff when I re-organize my parts tree.
Hi,

And welcome to the forum! :D

You forgot to post the 'about' info of your FreeCAD version (Help->About->Copy To Clipboard), without which it is difficult to say what is the problem. Certain v0.19dev versions have the bug you described, but it should be fixed in the later versions. Opening and re-saving all of the files in a newer version should fix it.

Example info:

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22665 (Git)
Build type: Release
Branch: master
Hash: b0d7850406e046f3b7a8cd5da261e7d54df6bd99
Python version: 3.8.6
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United Kingdom (en_GB)
realthunder
Posts: 1810
Joined: Tue Jan 03, 2017 10:55 am

Re: Assembly4: XLink absolute filepath problem

Postby realthunder » Thu Oct 15, 2020 10:32 am

michaelquigley wrote:
Thu Oct 15, 2020 4:55 am
But I can't figure out any way to FIX the links. I really wouldn't even mind manually editing the link paths and pointing them to where they should be... but for the life of me, I can't seem to find a way. It sounds to me like the relative path solution that's in place now is pretty sensible. Using a LIBRARY_PATH scheme might make that even slicker. But I'd really just like to be able to fix this stuff when I re-organize my parts tree.
One way is to unzip and manually edit xml, and then use the project utility to re-zip as mentioned by @project4.

If you are on Linux/MacOS, the easiest way is to create symlink. You can also create symlink on Windows, I've tried that years ago. You might want to search for that, e.g. this.

Another way is to just open the broken file. The broken links will be marked with a red exclamation mark in the tree view. Mouse over those objects, you'll get the file path and object name. You can manually open the corresponding file, find the object, and drag the object and drop to the link to re-establish the linking. You may want to mark the document for 'Skip recompute' (right click the document icon and select the action in the menu), and reenable recompute after you have finished fixing all the links.
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: 1103
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly4: XLink absolute filepath problem

Postby Zolko » Thu Oct 15, 2020 12:00 pm

michaelquigley wrote:
Thu Oct 15, 2020 4:55 am
But I can't figure out any way to FIX the links. I really wouldn't even mind manually editing the link paths and pointing them to where they should be... but for the life of me, I can't seem to find a way
I don't know whether Asm3 links are different from standard App::Links, but for standard App::Links you can edit a broken link from the GUI:

Select the broken link in the Model tree, then in its PropertyView select the small button for LinkedObject, and in the pop-up list select the new target object. Note that only already opened document will be show here, so you need to have the target document already opened. Note also that this supposes that all referenced datums in the old target object are present in the new target object. Else, you're on your own.

change_link.png
change_link.png (456.7 KiB) Viewed 122 times
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
michaelquigley
Posts: 19
Joined: Thu Oct 15, 2020 4:27 am

Re: Assembly4: XLink absolute filepath problem

Postby michaelquigley » Thu Oct 15, 2020 2:11 pm

project4 wrote:
Thu Oct 15, 2020 7:02 am
Go go "Tools -> Project Utility"
That's the way to ZIP the changed files into the FTStd again
I actually found that last night, after I posted. It's slightly painful in that in my early work with it, I ended up having to explode the FCStd in the location where I want the final project file to end up, because when I went to re-create the FCStd it validated the paths and failed to create the project if the paths were broken.

I wonder how painful it would be to create a command-line tool to do the extract/re-create, possibly without path validation... because if that were feasible, it might be pretty easy to create tools that can fix up a whole bunch of FCStd documents automatically when tree reorganizations happen.
michaelquigley
Posts: 19
Joined: Thu Oct 15, 2020 4:27 am

Re: Assembly4: XLink absolute filepath problem

Postby michaelquigley » Thu Oct 15, 2020 2:12 pm

aapo wrote:
Thu Oct 15, 2020 8:13 am
You forgot to post the 'about' info of your FreeCAD version (Help->About->Copy To Clipboard), without which it is difficult to say what is the problem. Certain v0.19dev versions have the bug you described, but it should be fixed in the later versions. Opening and re-saving all of the files in a newer version should fix it.
I didn't post that information because I didn't think I was reporting a "bug". I was assuming this is/was just a part of the design of the software.