[Link Bug ?] Not All Objects Loaded when there's Link to External Doc ?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
paullee
Veteran
Posts: 5118
Joined: Wed May 04, 2016 3:58 pm

[Link Bug ?] Not All Objects Loaded when there's Link to External Doc ?

Post by paullee »

Just can find a discussion with little relevance https://forum.freecadweb.org/viewtopic.php?f=3&t=57585. Try to single out the case below partly illustrate the situation.

Summary

In short, I have a SketchObjectPython which onDocumentRestore() call its parents to run some methods. The model file opens and it runs without problem, until a Link to another External Document is added, then it seems a lots of objects are not loaded (both in Linked and Link documents !?) and return 'NoneType' error below.

Code: Select all

09:56:57  Traceback (most recent call last):
  File "/home/paullee/Downloads/FreeCAD_0.20_weekly-builds-25025-Linux-Conda_glibc2.12-x86_64_vanilla/squashfs-root/usr/Mod/Link to SketchArchLite/ArchSketchObject.py", line 409, in onDocumentRestored
    self.callParentToRebuildMasterSketchTags(fp) # "Master"			
  File "/home/paullee/Downloads/FreeCAD_0.20_weekly-builds-25025-Linux-Conda_glibc2.12-x86_64_vanilla/squashfs-root/usr/Mod/Link to SketchArchLite/ArchSketchObject.py", line 310, in callParentToRebuildMasterSketchTags
    parent.Proxy.setPropertiesLinkCommon(parent)
    
<class 'AttributeError'>: 'NoneType' object has no attribute 'Proxy'
Details and Demo Model Files

Demo Model Files
  1. See screencapture of 2 demo files with dependency graphs in images 1 & 2 below
    (Model files attached below)
  2. There are SketchObjectPython objects therein with onDocumentRestore() methods
  3. The object is called ArchSketch, and its has appLinkExecute() to support Link also :)
  4. Both models file have 2 ArchSketches
    (name it ArchSketch__Master_x, and ArchSketch__Dependent_x respectively)
  5. Both ArchSketch__Dependent_x has an App::PropertyLink, point it to ArchSketch__Master_x
  6. Save and re-open
  7. The onDocumentRestore() run and the ArchSketch__Master_x find its parent ArchSketch__Dependent_x to run relevant methods()
  8. So far so good :)
For the SketchObject Python object details see experimental addon - https://github.com/paullee0/FreeCAD_SketchArch

Link to External Doc
  1. Add a Link in one model to another document and save both files
  2. Open the model file with Link, it seems partial open the Documents
  3. It seems then, there are objects ( both in the Link and Linked Document ) can't be gotten and return NoneType errors
  4. Though in the attached Demo files, Only in the Link File the dependent/parent object can't be found and return NonType error
  5. Noted, in the demo Linked file, only the Link object ( but not the object ArchSketch__Dependent_1 which has PropertyLink to the ArchSketch__Master_1) is found in the fp.Inlist
    (fp.Inlist should include PropertyLink ArchSketch__Dependent_1 as shown in the dependency graph)

    Code: Select all

    10:57:29   fp.InList is -  [<App::Link object>]
  6. So, there is no error return in this demo for those object in Linked model file (as they are not called)
    (Can't yet single out the scenario / simplify the model files with both Linked / Link files return errors)
Temporary Workaround ?
  1. Tried the "Disable partial loading of External Linked Objects"
  2. Still in complicated model, there are still traceback error complain Nonetype object, both in Linked and Link model files
  3. Tried open the 'Linked Document' first ( no compliant of cos), then the Link File
  4. Curiously, it seem on first open, there is still error; but on 2nd open of the Link File, no complaint ?
  5. For the attached demo mode files, "Disable partial loading of External Linked Objects" helps and no more complaints !
    (Curious, though seem not a full 'fix', any way to Disable partial loading 'built-in' a model file, w/o user manual intervention ?)
Test_ Link_ Partial Doc Loading_ Link Doc.FCStd
(12.81 KiB) Downloaded 11 times
.
Model File with Linked Object, and Parent/Child ArchSketch Objects
Screenshot from 2021-07-31 18-53-18.png
Screenshot from 2021-07-31 18-53-18.png (259.26 KiB) Viewed 853 times
.
Model File with Link, and Parent/Child ArchSketch Objects
Screenshot from 2021-07-31 19-10-06.png
Screenshot from 2021-07-31 19-10-06.png (246.35 KiB) Viewed 853 times
.
On opening of File with Link, Error returned
Screenshot from 2021-07-31 19-13-01.png
Screenshot from 2021-07-31 19-13-01.png (266.87 KiB) Viewed 853 times
realthunder wrote: Ping
See if you have any idea ? Thanks !


OS: Fedora 31 (Workstation Edition) (GNOME/gnome)
Word size of FreeCAD: 64-bit
Version: 0.20.25025 (Git)
Build type: Release
Branch: master
Hash: fb8b21ec43dca706a4aa2d63d59a4fb79f050369
Python version: 3.9.4
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.2
Locale: English/United States (en_US)
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: [Link Bug ?] Not All Objects Loaded when there's Link to External Doc ?

Post by realthunder »

I have just submitted a PR to fix the problem reported in your quoted post. The cause of the problem is in the PR description.
Try Assembly3 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
paullee
Veteran
Posts: 5118
Joined: Wed May 04, 2016 3:58 pm

Re: [Link Bug ?] Not All Objects Loaded when there's Link to External Doc ?

Post by paullee »

Glad to know that a fix is already available for the related issue :)
Post Reply