Part_Sweep: cannot use SubLink edge for path

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Part_Sweep: cannot use SubLink edge for path

Post by Roy_043 »

The new version of Part_Sweep should support Links for the profile and the path. But somehow selecting an edge from a SubLink for the path does not work. The result is an error: "Unhandled unknown exception caught in GUIApplication::notify." And the task panel cannot be closed with the OK button.

Open the attached file, use Cube002 as the profile, and Cube001 as the path.

Code: Select all

OS: Windows 8.1 (6.3)
Word size of FreeCAD: 64-bit
Version: 0.20.28671 (Git)
Build type: Release
Python 3.8.13, Qt 5.12.9, Coin 4.0.0, OCC 7.5.3
Locale: Dutch/Netherlands (nl_NL)
Installed mods: 
Attachments
Part_Sweep_SubLink_Path.FCStd
(7.67 KiB) Downloaded 40 times
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: Part_Sweep: cannot use SubLink edge for path

Post by Roy_043 »

Part_Revolve has a similar issue. You cannot select an edge from a SubLink as the axis reference.
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

Re: Part_Sweep: cannot use SubLink edge for path

Post by kisolre »

CheckGeometry of Cube002 shows that the checked geometry is Cube and not the linked compound Cube002.
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: Part_Sweep: cannot use SubLink edge for path

Post by Roy_043 »

kisolre wrote: Fri Apr 15, 2022 7:19 am CheckGeometry of Cube002 shows that the checked geometry is Cube and not the linked compound Cube002.
See https://forum.freecadweb.org/viewtopic.php?f=3&t=67961

The issue is related, but perhaps different?
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Part_Sweep: cannot use SubLink edge for path

Post by TheMarkster »

I am looking into the issue with Sweep. It does not appear to be an issue with the sweep object itself. As a test you can create the sweep using a different spine, then edit the spine to use the sublink and all works as expected. The issue therefore is probably somewhere in the dialog.
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Part_Sweep: cannot use SubLink edge for path

Post by TheMarkster »

When a sublink is preselected look at the status bar:
Snip macro screenshot-beddb8.png
Snip macro screenshot-beddb8.png (53.75 KiB) Viewed 1580 times
It shows Edge9 even though this sublink object only has one edge, which would be Edge1. Then when the sublink's topo shape is acquired and TopoShape::getSubShape('Edge9') is called on it, then I think that is where it fails because this topo shape has no edge 9.

https://github.com/FreeCAD/FreeCAD/blob ... p.cpp#L303

Code: Select all

    bool ok = true;
    if (selobjs.size() == 1) {
        selection = selobjs[0].getAsPropertyLinkSubString();
        const std::vector<std::string>& subnames = selobjs[0].getSubNames();
        docobj = selobjs[0].getObject();
        spineObject = selobjs[0].getFeatName();
        spineLabel = docobj->Label.getValue();
        topoShape = Part::Feature::getTopoShape(docobj);
        if (!topoShape.isNull()) {
            for (std::vector<std::string>::const_iterator it = subnames.begin(); it != subnames.end(); ++it) {
                subShapes.push_back(topoShape.getSubShape(subnames[0].c_str()));                                     //<<<--- fails here --->>>
            }
            for (std::vector<Part::TopoShape>::iterator it = subShapes.begin(); it != subShapes.end(); ++it) {
                TopoDS_Shape dsShape = (*it).getShape();
                if (dsShape.IsNull() || dsShape.ShapeType() != TopAbs_EDGE) { //only edge selection allowed
                    ok = false;
                }
            }
        } else { //could be not a part::feature or app:link to non-part::feature or app::part without a visible part::feature
            ok = false;
        }

    } else { //not just one object selected
        ok = false;
    }
It looks like sublinks are going to be problematic where the property type is PropertyLinkSub or PropertyLinkSubList. We might just have to document this as a limitation.

I stated above that the Sweep object works if we create it with a different spine, and then edit the property to point to the sublink. This is true to an extent, but only where the entire sublink object is used or if we use Edge1 for sublinks that only have 1 edge.
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: Part_Sweep: cannot use SubLink edge for path

Post by Roy_043 »

If the SubLink contains only a single edge the problem can easily be solved.

For other cases something like this may work:

Code: Select all

sel = Gui.Selection.getSelectionEx("", 0)
sel = sel[0]
lnk = sel.Object
sel_sub_name = sel.SubElementNames[0]
sel_sub_idx = lnk.LinkedObject[1].index(sel_sub_name)

lnk_shp = Part.getShape(lnk)
lnk_shp_sub = lnk_shp.SubShapes[sel_sub_idx]

print(lnk_shp_sub.Vertexes[0].Point)
print(lnk_shp_sub.Vertexes[1].Point)
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Part_Sweep: cannot use SubLink edge for path

Post by TheMarkster »

Realthunder has offered a suggestion on github. His suggestion works, but in my tests I am getting a crash with this test file. I don't expect it to produce a valid sweep, but a crash is not ideal.

If I make simple copies of these objects in Part workbench and use the simple copies it still crashes. In 0.19, I get a message that there was a fatal error, but no crash. In current master (or at least a recent build) the sweep with the copies works, sort of. It doesn't look right, but it produces an object.
Snip macro screenshot-85055c.png
Snip macro screenshot-85055c.png (33.16 KiB) Viewed 1460 times
I shall need to investigate further the crash and see if it can be prevented when I have some more time later today.
Attachments
sweep_test.FCStd
(4.57 KiB) Downloaded 26 times
User avatar
Aleks
Posts: 309
Joined: Sun Mar 08, 2020 5:27 pm
Location: Bonn, Germany
Contact:

Re: Part_Sweep: cannot use SubLink edge for path

Post by Aleks »

coming from:
https://forum.freecadweb.org/viewtopic.php?f=22&t=68398

Why does that even matter:

Code: Select all

sel_sub_idx = lnk.LinkedObject[1].index(sel_sub_name)
Isnt the index here totally different than the one in the shape?
FreeCAD als Maschinenbauer in die Konstruktion und Fertigung integrieren. Schulung buchen: www.alsado.de/freecad-schulungen
Post Reply