The modified script:
import Part, FreeCAD, math, PartGui, FreeCADGui
from FreeCAD import Base
# pick selected objects, where 1st selection is the trajectory and the 2nd and next are the sections to sweep
s = FreeCADGui.Selection.getSelection()
num=len(FreeCADGui.Selection.getSelection())#number of selected objects
traj = Part.Wire([s.Shape])#first wire is a trajectory
for i in range(1, num):
if i == 1:
sectionlist = [Part.Wire([s.Shape])]#at least one section is necessary
elif i > 1:
sectionlist = sectionlist + [Part.Wire([s[i].Shape])]
print "Wrong selection"
# create a Part object into the active document
makeSolid = 1
isFrenet = 1
# Create the 3D shape and set it to the Part object
VariableSectionSweep = Part.Wire(traj).makePipeShell(sectionlist,makeSolid,isFrenet)
myObject.Shape = VariableSectionSweep
Recipe for very simple manifold-like variable section pipeYou need (at least) three sketches:
- trajectory constructed from tangent segments, normal to section sketches,
- section sketch at the start of trajectory,
- section sketch at the end of trajectory.
Close the sketch (Sketch) and create a new one on the plane YZ. Rotate slightly view to show trajectory and draw a rectangle.
Add fillets and other constraints as in the image below. Then close the sketch (Sketch001).
Create second sketch on the YZ plane, but this time with offset 500. Draw a circle.
The effect should look like in the below image. You should have three sketches: Sketch (for trajectory), Sketch001 (for first section) and Sketch002 (for second section). Select them in Three view (order is important) with [Ctrl] and execute script (paste it in Python console or save as macro - see previous tutorials).
Now you should have a solid.
The simplest way to create a hollow pipe is boolean cut of two different solids. Let's create second, smaller sweep. Select Sketch001 and use Edit-Duplicate selection. Retry operation for Sketch002. Two new sketches: Sketch003 and Sketch004 will be visible in Three view.
Edit Sketch003 - change dimensions to smaller values.
Do exactly the same thing with Sketch004.
Then select Sketch, Sketch003 and Sketch004 and execute the script. When you get second sweep, open Part workbench, select both sweeps and use boolean cut.
The final effect:
Check the final shape with View-Clipping plane tool.
Download RAW Video.
Version: 0.13.0964 (Git)
Update:Latest FreeCAD has a GUI tool for sweeps. It can be found in Part Workbench, Part-Sweep... menu.
You should select (put in the Sweep field) sketches for section in Task View and select a sketch for trajectory in 3D view. For more informations check this topic.
Support introduced (for PPA) in:
Version: 0.13.1116 (Git)