Ticket #4462: Upgrade from shell to solid failed - UnboundLocalError

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
Kunda1
Posts: 8772
Joined: Thu Jan 05, 2017 9:03 pm

Ticket #4462: Upgrade from shell to solid failed - UnboundLocalError

Postby Kunda1 » Thu Oct 15, 2020 9:19 pm

Discussion thread for: issue #4462: Upgrade from shell to solid failed - UnboundLocalError
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
chrisb
Posts: 29062
Joined: Tue Mar 17, 2015 9:14 am

Re: Ticket #4462: Upgrade from shell to solid failed - UnboundLocalError

Postby chrisb » Thu Oct 15, 2020 10:47 pm

Fixed in this version, ticket closed.

OS: macOS 10.15
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22670 (Git)
Build type: Release
Branch: master
Hash: 12155f4aab09047c5697db0c1b3cf93b02edda03
Python version: 3.8.6
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: C/Default (C)
A Sketcher Lecture with in-depth information is available in English, auf deutsch, en français, en español.
User avatar
Kunda1
Posts: 8772
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #4462: Upgrade from shell to solid failed - UnboundLocalError

Postby Kunda1 » Fri Oct 16, 2020 12:47 am

chrisb wrote:
Thu Oct 15, 2020 10:47 pm
Fixed in this version, ticket closed.
Great. Do we have a git commit associated with the fix?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
HardRock
Posts: 76
Joined: Tue Mar 13, 2018 5:50 am
Location: Russian Federation

Re: Ticket #4462: Upgrade from shell to solid failed - UnboundLocalError

Postby HardRock » Fri Oct 16, 2020 4:33 am

I have use freecad-daily package for Ubuntu 18.04 and updating when new version come.
In today update still reproduced.

OS: Ubuntu 18.04.4 LTS (Unity:Unity7:ubuntu/unity)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Branch: unknown
Hash: df9282dc12d45996bb83cb42f6da10fd82519a47
Python version: 3.6.9
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Russian/Russia (ru_RU)

How long it took from commit to freecad-daily package? May be better to compile from sources from github? (i'm developer too, so i can do it)
jmaustpc
Posts: 10382
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Ticket #4462: Upgrade from shell to solid failed - UnboundLocalError

Postby jmaustpc » Fri Oct 16, 2020 7:55 am

HardRock wrote:
Fri Oct 16, 2020 4:33 am
How long it took from commit to freecad-daily package?
Once daily
HardRock wrote:
Fri Oct 16, 2020 4:33 am
May be better to compile from sources from github? (i'm developer too, so i can do it)
If you can test and contribute in any way, that could be useful. Normally the compiled versions are not installed. unlike the daily ppa versions, since they can just be directly run once compile and before FreeCAD is installed by running the FreeCAD executable file in the Bin directory under the compile directory.
jmaustpc
Posts: 10382
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Ticket #4462: Upgrade from shell to solid failed - UnboundLocalError

Postby jmaustpc » Fri Oct 16, 2020 8:19 am

Many of the original faces do not pass the check geometry test. So it is expected that this would not work.

Just select the first face, then hold the Shift key (whatever the equivalent is on Apple) while you click on the last face, then they will all high light, then run Part WB check geometry on all those faces, you will find many are not valid, I think it was 8.

Please ask and confirm that you in fact found a bug before creating tickets on the bug tracker.

So that I guess now resolves this specific issue however opens the next question which was the real question all along for both topics and tickets, how did you create those non-valid faces?

This is a copy of the FCstd file originally from the ticket.
bug_upgrade_from_shell_to_solid_failed(1).FCStd
(797.46 KiB) Downloaded 7 times
HardRock
Posts: 76
Joined: Tue Mar 13, 2018 5:50 am
Location: Russian Federation

Re: Ticket #4462: Upgrade from shell to solid failed - UnboundLocalError

Postby HardRock » Fri Oct 16, 2020 10:23 am

All was created with standard tools (Part / Surface / Sketch WB) and Cuves workbench to make unbound edges for surrfaces of "square parts" that immitates rag cover.

I'm unable to attach file because it 1.4mb :(

Take a look at the complete model https://forum.freecadweb.org/viewtopic.php?f=24&t=51078

1. Wing was created as surfaces between profiles
2. Sketch (top view) with lines (not solid, not closed) for cut aileron from wing was extruded and aileron was cutted with Part - Slice Apart
3. Sketch (top view) with geometry of "holes" was extruded as solid and cutted from aileron to make holes
4. Using Curves WB extra edges was made in each hole
5. Using Surface WB holes was filled, extra edge from #4 used as unbound edge to make surface twist
6. Round part profile of front of aileron was made with sketches
7. Walls was created with Surface WB - Fill surface, and Part Ruled Surface
8. Part Create shell from faces used to make single shell and lose history

This is completly "clean, simple and legal" way.

In test file I have used Draft Downgrade to split into faces just for test.

May be bug somewhere before in surface operations.

When you work with something complex than cubes, spheres and other simple geometry, this problem occurs very often.
Straight lines and solids - no problem, curved lines and surfaces - pain :)
User avatar
Kunda1
Posts: 8772
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #4462: Upgrade from shell to solid failed - UnboundLocalError

Postby Kunda1 » Fri Oct 16, 2020 11:19 am

HardRock wrote:
Fri Oct 16, 2020 10:23 am
I'm unable to attach file because it 1.4mb :(
please use dropbox or some 3rd party hosting to share file
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
HardRock
Posts: 76
Joined: Tue Mar 13, 2018 5:50 am
Location: Russian Federation

Re: Ticket #4462: Upgrade from shell to solid failed - UnboundLocalError

Postby HardRock » Fri Oct 16, 2020 11:46 am

Here is it. This part have some difference from file that was attached in ticket because some intermediate history was lost.
I have redraw round part of aileron (tho sketches and extra walls). Ofcource, same result :)

https://dropmefiles.com/rDgkm

Main problem that you can't predict when errors appear. You may create few parts with same workflow and some of them will contain hidden errors.
Or you interracting with part (cutting, splitting, adding other faces) and all goes right, but after number of operations you may find that something gone wrong and now you are not able to proceed.
openBrain
Posts: 4874
Joined: Fri Nov 09, 2018 5:38 pm

Re: Ticket #4462: Upgrade from shell to solid failed - UnboundLocalError

Postby openBrain » Fri Oct 16, 2020 11:59 am

In the example file, the problem is the sewing between the wing front (curved face) and the 2 wing flat faces which isn't correct.
Here is an example that displays the distance between Edge4 of Face014 and Edge4 of Face026 (which is the upper seam).

Code: Select all

>>> diff = lambda x:[(a-b).Length for a,b in zip(App.ActiveDocument.Face014.Shape.Edges[3].discretize(x), App.ActiveDocument.Face026.Shape.Edges[3].discretize(x)[::-1])]
>>> diff(10)
[9.99875737761613e-11, 0.0057411924906165274, 0.010389548255119249, 0.013829369855245206, 0.015928036251299498, 0.016532780350876904, 0.01546673187354468, 0.0125239386577204, 0.007463171788635805, 9.99925751616207e-11]
While the gap is very tight (not perfect though) at the 2 endpoints, it grows up to 16 µm around the center.
Thus no surprise that FreeCAD can't get a solid from the shell as this latter isn't perfectly closed. ;)