Sunday, May 27, 2012

Variable section pipe

Some engine parts like manifolds can be modelled as sweeps. I showed a sweep script which used two wires/sketches: first for trajectory and second for section. What if you need variable section? Fortunately makePipeShell is able to handle many section wires.

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[0].Shape])#first wire is a trajectory
    for i in range(1, num):
        if i == 1:
            sectionlist = [Part.Wire([s[1].Shape])]#at least one section is necessary
        elif i > 1:
            sectionlist = sectionlist + [Part.Wire([s[i].Shape])]
            #print i

    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 pipe

You need (at least) three sketches:
  1. trajectory constructed from tangent segments, normal to section sketches,
  2. section sketch at the start of trajectory,
  3. section sketch at the end of trajectory.
Create a new sketch on the XY plane. Draw an arc (center at 0,0, radius 300) and horizontal line (length = 500) as in the image below. This is the 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 file.

Download RAW Video.

Version: 0.13.0964 (Git)
Branch: master
Hash: 1b70aef0f2dda3db0639b706c48a2469688dc93c


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)
Branch: master
Hash: 6a2a72627635d9b72d24fa90312586e7967e6f8c

No comments:

Post a Comment