Crash with Sweep

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
hokieengr
Posts: 62
Joined: Sat Dec 31, 2016 5:09 pm

Crash with Sweep

Post by hokieengr »

As may of you know, the Part Design Sweep function typically crashes FreeCAD. This seems to be common knowledge, however, I did not see a bug report for it.

Is anyone working this and/or mind if I submit a bug report so we can fix it?

Thank you!
Bob
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Crash with Sweep

Post by NormandC »

Hi,

Yes it's prone to crashing, but not 100% of the time. Not sure if by saying "typically crashes FreeCAD" you meant 100% of the time?

Would you please detail a procedure that ensures a crash so we can test it? Providing a test file would be best. And please report your FreeCAD info as explained in the Help forum "Read first" topic: https://forum.freecadweb.org/viewtopic.php?f=3&t=2264

Thanks.
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: Crash with Sweep

Post by mlampert »

I noticed the other day that if you sweep along a closed wire it crashes deterministically.
chrisb
Veteran
Posts: 54150
Joined: Tue Mar 17, 2015 9:14 am

Re: Crash with Sweep

Post by chrisb »

I cannot second that. I attach a file with a handmade torus. I started with a sketch for the closed path, and tried with an edge and wire as well, all with the same result.
Attachments
sweepClosedPath.FCStd
(4.83 KiB) Downloaded 123 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: Crash with Sweep

Post by mlampert »

OK, I've isolated the test case. If you sweep Shape001 along any part of Shape (in the attached file), it will succeeed. If you try to sweep Shape001 along all 8 segments of Shape you'll get a segfault in

Code: Select all

TopoDS_ListIteratorOfListOfShape::Initialize(....)
Attachments
sweep.fcstd
(3.6 KiB) Downloaded 97 times
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Crash with Sweep

Post by jnxd »

Found one problem. ViewProviderPipe.cpp:144 should have assert(idx>=0) instead of idx>0.

However doesn't address some other issues, apparently. For instance, I can't create a closed sweep. Also, when I click OK, 3 options pop up, and selecting the first two crashes FreeCAD.
My latest (or last) project: B-spline Construction Project.
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Crash with Sweep

Post by NormandC »

Guys,

I really get the feeling there's a huge misunderstanding in this topic. IMO it is about the new PartDesign sweep feature in 0.17. There is an Image Additive pipe feature and a Image Subtractive pipe feature.

Here's the relevant quote from Bob's first entry:
hokieengr wrote:As may of you know, the Part Design Sweep function typically crashes FreeCAD.
While the "old" Part Sweep is pretty stable, it's true that the new pipe/sweep features in 0.17's PartDesignNext can cause crashes.

Bob (hokieengr), could you please confirm you were talking about the new PartDesignNext sweep features, and if so, please edit your first post and change the subject to "Crash with PartDesign Additive/Subtractive pipe" so we can avoid confusion.

Thanks.

jnxd wrote:Also, when I click OK, 3 options pop up, and selecting the first two crashes FreeCAD.
Could you please mention which file you tried, and if you actually made an additive/subtractive pipe, as well as explain what that pop up is. Thanks.
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: Crash with Sweep

Post by mlampert »

NormandC wrote:Guys,

I really get the feeling there's a huge misunderstanding in this topic. IMO it is about the new PartDesign sweep feature in 0.17.
You are correct - the sweep I was using and that crashes FC reliably with the file attached above is Sweep from Part, not PartDesign. I haven't used Sweep from PartDesign, but the one from Part is less than stable.
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Crash with Sweep

Post by jnxd »

I am talking of PartDesignNext's Additive Pipe. I start the following macro

Code: Select all

# -*- coding: utf-8 -*-

# Macro Begin: /home/ajinkya/.FreeCAD/Macros/SweepBug.FCMacro +++++++++++++++++++++++++++++++++++++++++++++++++
import FreeCAD
import Part
import PartDesign
import PartDesignGui
import Sketcher

#ActiveSketch = App.ActiveDocument.getObject('Sketch')
#tv = ActiveSketch.ViewObject.TempoVis
#if tv:
#  tv.restore()
#ActiveSketch.ViewObject.TempoVis = None
#del(tv)
#
Gui.activateWorkbench('PartDesignWorkbench')
App.newDocument("Unnamed")
#App.setActiveDocument("Unnamed")
#App.ActiveDocument=App.getDocument("Unnamed")
#Gui.ActiveDocument=Gui.getDocument("Unnamed")
App.activeDocument().addObject('PartDesign::Body','Body')
#Gui.activeView().setActiveObject('pdbody', App.activeDocument().Body)
#Gui.Selection.clearSelection()
#Gui.Selection.addSelection(App.ActiveDocument.Body)
App.ActiveDocument.recompute()
App.activeDocument().addObject('Sketcher::SketchObject','Sketch')
App.activeDocument().Sketch.Support = (App.activeDocument().XY_Plane, [''])
App.activeDocument().Sketch.MapMode = 'FlatFace'
App.ActiveDocument.recompute()
App.activeDocument().Body.addObject(App.activeDocument().Sketch)
#Gui.activeDocument().setEdit('Sketch')
#Gui.activateWorkbench('SketcherWorkbench')
#ActiveSketch = App.ActiveDocument.getObject('Sketch')
#tv = Show.TempoVis(App.ActiveDocument)
#if ActiveSketch.ViewObject.HideDependent:
#  tv.hide_all_dependent(ActiveSketch)
#if ActiveSketch.ViewObject.ShowSupport:
#  tv.show([ref[0] for ref in ActiveSketch.Support])
#if ActiveSketch.ViewObject.ShowLinks:
#  tv.show([ref[0] for ref in ActiveSketch.ExternalGeometry])
#tv.hide(ActiveSketch)
#ActiveSketch.ViewObject.TempoVis = tv
#del(tv)
#
#ActiveSketch = App.ActiveDocument.getObject('Sketch')
#if ActiveSketch.ViewObject.RestoreCamera:
#  ActiveSketch.ViewObject.TempoVis.saveCamera()
#
geoList = []
geoList.append(Part.LineSegment(App.Vector(0.000017,-0.000008,0),App.Vector(29.684902,-0.000008,0)))
geoList.append(Part.LineSegment(App.Vector(29.684902,-0.000008,0),App.Vector(29.684902,30.115644,0)))
geoList.append(Part.LineSegment(App.Vector(29.684902,30.115644,0),App.Vector(0.000017,30.115644,0)))
geoList.append(Part.LineSegment(App.Vector(0.000017,30.115644,0),App.Vector(0.000017,-0.000008,0)))
App.ActiveDocument.Sketch.addGeometry(geoList,False)
conList = []
conList.append(Sketcher.Constraint('Coincident',0,2,1,1))
conList.append(Sketcher.Constraint('Coincident',1,2,2,1))
conList.append(Sketcher.Constraint('Coincident',2,2,3,1))
conList.append(Sketcher.Constraint('Coincident',3,2,0,1))
conList.append(Sketcher.Constraint('Horizontal',0))
conList.append(Sketcher.Constraint('Horizontal',2))
conList.append(Sketcher.Constraint('Vertical',1))
conList.append(Sketcher.Constraint('Vertical',3))
App.ActiveDocument.Sketch.addConstraint(conList)

App.ActiveDocument.Sketch.addConstraint(Sketcher.Constraint('Coincident',0,1,-1,1)) 
#Gui.getDocument('Unnamed').resetEdit()
#ActiveSketch = App.ActiveDocument.getObject('Sketch')
#tv = ActiveSketch.ViewObject.TempoVis
#if tv:
#  tv.restore()
#ActiveSketch.ViewObject.TempoVis = None
#del(tv)
#
#Gui.activateWorkbench('PartDesignWorkbench')
App.getDocument('Unnamed').recompute()
App.activeDocument().addObject('Sketcher::SketchObject','Sketch001')
App.activeDocument().Sketch001.Support = (App.activeDocument().XZ_Plane, [''])
App.activeDocument().Sketch001.MapMode = 'FlatFace'
App.ActiveDocument.recompute()
App.activeDocument().Body.addObject(App.activeDocument().Sketch001)
#Gui.activeDocument().setEdit('Sketch001')
#Gui.activateWorkbench('SketcherWorkbench')
#ActiveSketch = App.ActiveDocument.getObject('Sketch001')
#tv = Show.TempoVis(App.ActiveDocument)
#if ActiveSketch.ViewObject.HideDependent:
#  tv.hide_all_dependent(ActiveSketch)
#if ActiveSketch.ViewObject.ShowSupport:
#  tv.show([ref[0] for ref in ActiveSketch.Support])
#if ActiveSketch.ViewObject.ShowLinks:
#  tv.show([ref[0] for ref in ActiveSketch.ExternalGeometry])
#tv.hide(ActiveSketch)
#ActiveSketch.ViewObject.TempoVis = tv
#del(tv)
#
#ActiveSketch = App.ActiveDocument.getObject('Sketch001')
#if ActiveSketch.ViewObject.RestoreCamera:
#  ActiveSketch.ViewObject.TempoVis.saveCamera()
#
App.ActiveDocument.Sketch001.addGeometry(Part.Circle(App.Vector(0.001218,0.002344,0),App.Vector(0,0,1),7.576734),False)
App.ActiveDocument.Sketch001.addConstraint(Sketcher.Constraint('Coincident',0,3,-1,1)) 
App.ActiveDocument.Sketch001.addConstraint(Sketcher.Constraint('Radius',0,7.576734)) 
App.ActiveDocument.Sketch001.setDatum(1,App.Units.Quantity('5.000000 mm'))
#Gui.getDocument('Unnamed').resetEdit()
#ActiveSketch = App.ActiveDocument.getObject('Sketch001')
#tv = ActiveSketch.ViewObject.TempoVis
#if tv:
#  tv.restore()
#ActiveSketch.ViewObject.TempoVis = None
#del(tv)
#
#Gui.activateWorkbench('PartDesignWorkbench')
App.getDocument('Unnamed').recompute()
# Macro End: /home/ajinkya/.FreeCAD/Macros/SweepBug.FCMacro +++++++++++++++++++++++++++++++++++++++++++++++++
Once you've run this on an empty file, activate the body and attempt to sweep the circle using the tool along the edges of the square. You'll see that once you select "Edge1" (the one in the same plane as the circle, along the x-axis), an attempt to add an edge to the sweep will fail. I corrected that in my local repo, but even after that I cannot create a closed pipe along the sides of the square, despite being able to select all the edges (if you don't want to mess with the code, just add Edge1 last and never try to add or remove an edge after adding it).

Once I close the sketch, all edges selected or otherwise, this shows up:
Screenshot from 2017-02-01 08-49-08.png
Screenshot from 2017-02-01 08-49-08.png (27.65 KiB) Viewed 5386 times
Note that both sketches are in the VERY SAME body, which is also the active body! Though the independent copy option is "recommended", choosing it or the next option crashes FreeCAD instantly.

PS: Remind me, why do we have Part and PartDesign with all the duplicated efforts again?

Edits in blue.
My latest (or last) project: B-spline Construction Project.
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Crash with Sweep

Post by NormandC »

@jnxd

I ran your script and created an additive pipe, got a crash too. But what you are asking the program is impossible: you can't get a valid sweep either with Part Sweep, because the swept profile intersects itself in the corners.

The only way to get a valid sweep is to
  • Move the rectangle sketch so the Sketch001 is not in a corner
  • Move the circle sketch outside of the path so it won't intersect itself.
I agree it should not crash though.

Note that I just tested my recommendation and ended up with a crash nonetheless :D
jnxd wrote:Once I close the sketch, all edges selected or otherwise, this shows up:
That's baffling, I created a new file from scratch without using your recorded macro, making sure to create a Body first, and I get the same message. It's like PDN does not consider AdditivePipe to be a valid basis for a base feature?

FYI I tried with an open path and I get the same Dialog implying that the sketch path is outside of the Body. :?
jnxd wrote:PS: Remind me, why do we have Part and PartDesign with all the duplicated efforts again?
Was that a rhetorical question? :D

Ask jriegel if you're lucky enough to get a hold of him. But did you know that he originally didn't want Sweep/Loft in the Part workbench, not even in the PartDesign workbench? He considered these were advanced modelling tools that should only go in a SurfaceDesign workbench. Lucky for us he allowed the tools to be added in Part back in the day, or we would still be waiting.

BTW one fundamental difference between Part and PD is that the former can create any type of shape from vertex to solid, while the latter can only create solids.
Post Reply