[BUG?] Problems with partially loaded files in an Asm4 assembly

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
aapo
Posts: 625
Joined: Mon Oct 29, 2018 6:41 pm

[BUG?] Problems with partially loaded files in an Asm4 assembly

Post by aapo »

Hi!

I believe I've found a bug in the Asm4 assembly workbench, which involves deferred loading (partially loaded) files within an Asm4 assembly. The problem is that any Asm4 files that have their PartDesign Bodies in a "Parts" folder provided by the Asm4 workbench fail to display at all, if the files are only partially loaded. I've attached a simplified example, where there are two cubes on top of each other. The green one has a PartDesign Body directly inside the "Model" container, and this body displays correctly when only partially loaded. However, the red cube in file "20200707_Cube_1" only displays if the file is completely loaded, but the red cube is not shown if the file is only partially loaded. This can be demonstrated by downloading the 3 FCStd files below, and opening the file "20200707_Two_cubes.FCStd", which results in only the green cube visible. However, if the file with cube_1 is double-clicked, it loads fully, after which it'll also be visible in the main assembly ("20200707_Two_cubes.FCStd").

In practice, I simply doubleclick all partially loaded files in a model; but this is cumbersome if the model is large, and it also kind of kills the idea of partially loaded files. I'm not sure whether the root of the problem lies in the Link infrastructure or the Asm4 workbench.

Zolko wrote:ping
realthunder wrote:ping
20200707_screenshot_1.png
20200707_screenshot_1.png (19.5 KiB) Viewed 1342 times
20200707_screenshot_3.png
20200707_screenshot_3.png (34.36 KiB) Viewed 1335 times

OS: Debian GNU/Linux bullseye/sid (KDE//usr/share/xsessions/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.21875 (Git)
Build type: Unknown
Branch: master
Hash: a1bf9d63fa5d748f9ec7221b7d148a033a899d43
Python version: 3.8.4rc1
Qt version: 5.14.2
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)
Attachments
20200707_Cube_2.FCStd
(9.52 KiB) Downloaded 44 times
20200707_Cube_1.FCStd
(11.12 KiB) Downloaded 38 times
20200707_Two_cubes.FCStd
(6.19 KiB) Downloaded 45 times
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: [BUG?] Problems with partially loaded files in an Asm4 assembly

Post by Zolko »

aapo wrote: Mon Jul 06, 2020 11:22 pm I believe I've found a bug in the Asm4 assembly workbench, which involves deferred loading (partially loaded) files within an Asm4 assembly.
partial loading doesn't work with Asm4, you must disable it.
try the Assembly4 workbench for FreCAD — tutorials here and here
aapo
Posts: 625
Joined: Mon Oct 29, 2018 6:41 pm

Re: [BUG?] Problems with partially loaded files in an Asm4 assembly

Post by aapo »

Zolko wrote: Tue Jul 07, 2020 9:04 am partial loading doesn't work with Asm4, you must disable it.
Thanks, good to know!

I'll put the preferred work-around here, just in case someone else wonders how to do it:

Edit -> Preferences -> General -> Document : "Disable partial loading of external linked objects" (check this)
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: [BUG?] Problems with partially loaded files in an Asm4 assembly

Post by Zolko »

aapo wrote: Tue Jul 07, 2020 10:01 am
Zolko wrote: Tue Jul 07, 2020 9:04 am partial loading doesn't work with Asm4, you must disable it.
I'll put the preferred work-around here, just in case someone else wonders how to do it:

Edit -> Preferences -> General -> Document : "Disable partial loading of external linked objects" (check this)
Thanks. Actually, I don't know what "partial loading of documents" does (except that it doesn't always work)
try the Assembly4 workbench for FreCAD — tutorials here and here
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: [BUG?] Problems with partially loaded files in an Asm4 assembly

Post by realthunder »

This has to do with view object global coordinate space showability detection. This has been fixed in one my pending PR. I just submitted a smaller PR as a temporary fix.
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
aapo
Posts: 625
Joined: Mon Oct 29, 2018 6:41 pm

Re: [BUG?] Problems with partially loaded files in an Asm4 assembly

Post by aapo »

realthunder wrote: Tue Jul 07, 2020 10:57 am This has to do with view object global coordinate space showability detection. This has been fixed in one my pending PR. I just submitted a smaller PR as a temporary fix.
Thanks, great job there! :D Then I'll just leave the partial loading on, and wait for the fix to hit master, in order to test it.

BTW, In your pull request on line 244 if(_Showable && which == -1 && Visibility.getValue()) { the boolean variable _Showable is tested twice; first in the statement itself, and subsequently in a function call setModeSwitch() through if(isShowable()), which simply tests the same variable. At least for me, the intention would be clearer if it read

Code: Select all

    if (which == -1 && Visibility.getValue()) {
        setModeSwitch();
    } else if (which >= 0 && !_Showable) {
        ViewProvider::hide();
    }
instead of

Code: Select all

bool ViewProviderDocumentObject::isShowable() const
{
    return _Showable;
}

void ViewProviderDocumentObject::setShowable(bool enable)
{
    if (_Showable == enable)
        return;
    _Showable = enable;
    int which = getModeSwitch()->whichChild.getValue();
    if(_Showable && which == -1 && Visibility.getValue()) {
        setModeSwitch();
    } else if (!_Showable) {
        if(which >= 0)
            ViewProvider::hide();
    }
}

void ViewProviderDocumentObject::setModeSwitch() {
    if(isShowable())
        ViewProvider::setModeSwitch();
}

If I understand the problem correctly; the old code hides the ViewProvider object right away on lines 312-313 if there's nothing immediately showable at the current level, regardless of what could be available on its children; and the new code defers the decision until all children are checked. Looks good to me. :)
User avatar
fosselius
Posts: 381
Joined: Sat Apr 23, 2016 10:03 am
Contact:

Re: [BUG?] Problems with partially loaded files in an Asm4 assembly

Post by fosselius »

I have verified that the PR builds and runs fine, have not detected any issues. And it resolves the issue described in this thread.
Post Reply