Tuesday, September 25, 2012

"Part" Mirror vs "Part Design" Mirror

Some tools (Mirror, Chamfer, Fillet) seem duplicated in Part and Part Design Workbenches. Despite names, they work in slightly different ways. Part is designed for low-level operations on solids, Part Design is for higher level operations on features.

Part workbench Mirror

Start a new sketch. Draw a square or rectangle on XY plane and create a pad. The rectangle should be symmetric to axes. 

Make a pocket on a side face.

Open Part workbench, use the mirror (Mirroring a selected shape) tool and select a plane (YZ or XZ) in Tasks tab.

Confirm operation, now you should see second, mirrored solid. You can hide Pocket or Pocket (Mirror #1) with [Space]. 

Part Design workbench Mirror

Delete or hide Pocket (Mirror #1) and back to Part Design workbench. Select Pocket and use the mirror (Create a mirrored feature) tool. Set the plane to YZ (or XZ). As you can see, Part Design mirror works different. The pocket feature is mirrored instead the solid object.

Version: 0.13.1489 (Git)
Branch: master
Hash: a20f4dddffbe590434041373ee125b367ee60e31

Saturday, September 22, 2012

New Part Design features

Recent FreeCAD (see info at the bottom) introduces new Part Design features.

The updated Part Design toolbar, from the left side:
  • Create a sketch
  • Close the sketch
  • Pad
  • Pocket
  • Revolution
  • Groove
  • Fillet
  • Chamfer
  • Mirror
  • Linear pattern
  • Polar pattern
  • Multitransform (mirror, linear/polar pattern combined)

New functions - basics

Create an rectangle (sketch) on the XY plane. The rectangle should be symmetrical to X and Y axes (simply select two corners and an axis then click symmetrical constraint button).

Pad the sketch. Please notice new available options: type (Dimension, To last, To first, Up to face, Two dimensions) symmetrical (yes/no),  reversed (yes/no).

Select side face on the pad, and sketch a rectangle. It will be used for a groove feature. The groove is similar to pocket but material is removed around axis (like in a revolution).

Select the sketch and click Groove a selected sketch. Adjust angle and side in the Tasks tab. Note: sketches for almost all features (except pads) need a support face. The face should be selected before you start sketching - in other case use Map sketch to face from Part Design menu.

In next steps you will create a mirrored feature. Select the top face and sketch a circle.

Pocket the circle, set pocket type to Through all.

Select the pocket and use Create a mirrored feature. Set plane to XZ. Note: mirror of multiple holes can be unsupported in actual version of FreeCAD (implementation needed).

Linear pattern is an another useful function. Create a pad on side face, parallel to XZ plane.

Select the pad and use Create a linear pattern feature. Set direction to X, adjust length (should be lower than the body length) and occurrences number.

The most advances is a multitransform feature. You can mix linear and polar patterns and mirrored or scaled features. Select top face.

Sketch a circle close to (0,0) point.

Pad the circle.

Use Create a multitransform feature. Right click in the Transformations text area and then Add linear pattern.

Set occurrences to 2 and direction to X.

Then you can Add polar pattern in similar way. The direction is Z and occurrences is 5 (experiment with them!).

I want add XY mirror but in this case body must be symmetrical to XY. Edit the first pad - set Type to Symmetric to plane.

Now you can finish edit the multitransform feature. Use right click to Add mirrored transformation. Set plane to XY.

The final effect:

Download file.

Download RAW Video.

FreeCAD version:
Version: 0.13.1486 (Git)
Branch: master
Hash: aaaa7eb30313e25614b7f1b95b544788d8fa99fc

Tuesday, September 18, 2012

First FreeCAD book has been published

FreeCAD: Solid Modeling with the Power of Python (authors: Daniel Falck, Brad Collette) has been published. 70 pages, English. More info:

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

Tuesday, March 13, 2012

Mass and geometry properties (my scratchpad)

Volume, center of mass and matrix of inertia

For all solids you can get:
  1. volume - add Shape.Volume attribute to object,
  2. center of mass - add Shape.CenterOfMass attribute,
  3. matrix of inertia - add Shape.MatrixOfInertia attribute.
Cone (height = 40 mm, radius = 30 mm) named "Revolution"

>>> App.ActiveDocument.getObject("Revolution").Shape.MatrixOfInertia
Matrix ((7.35133e+06,-6.48484e-11,2.72874e-09,0),(-6.48484e-11,7.35133e+06,4.02739e-10,0),(2.72874e-09,4.02739e-10,1.01788e+07,0),(0,0,0,1))
>>> App.ActiveDocument.getObject("Revolution").Shape.CenterOfMass
Vector (6.11835e-15, 6.99401e-16, 30)
>>> App.ActiveDocument.getObject("Revolution").Shape.Volume

MatrixOfInertia attribute output needs some explanation:
Returns the matrix of inertia. It is a symmetrical matrix.
The coefficients of the matrix are the quadratic moments of inertia.

 | Ixx Ixy Ixz 0 |
 | Ixy Iyy Iyz 0 |
 | Ixz Iyz Izz 0 |
 | 0 0 0 1 |

The moments of inertia are denoted by Ixx, Iyy, Izz.
The products of inertia are denoted by Ixy, Ixz, Iyz.
The matrix of inertia is returned in the central coordinate system (G, Gx, Gy, Gz) where G is the centre of mass of the system and Gx, Gy, Gz the directions parallel to the X(1,0,0) Y(0,1,0) Z(0,0,1) directions of the absolute cartesian coordinate system.
So, we have 3 moments of inertia:

Further explanation - FreeCAD forum.

Area of face

You can measure area of face, simply add Area attribute. If you need area of a sketch, convert one to a face:
>>> face = Part.Face(App.ActiveDocument.getObject("Sketch").Shape)
>>> face.Area

If you have a solid (eg. a Pad), select face or faces on the solid object, and use this script:

area = 0.0
for o in Gui.Selection.getSelectionEx() :
        for s in o.SubObjects:
                area = s.Area
                print "Area of selected face:" ,area

Saturday, January 14, 2012

Engine: 10 - piston

Time for something more complicated. A piston.
Open the Part Design workbench and create a new document. 

Start sketching on the XY plane. Set left top corner at (0,0). The piston diameter is 75 mm, so top horizontal line should be 37.5.

You can see complete sketch above. If you cannot see dimensions of piston rings grooves, here is table (ring grooves enumerated from top):

Height [mm] Width [mm]
Gap 7 -
Groove 1 1.75 3
Gap 4 -
Groove 2 2 3.6
Gap 4 -
Groove 3
(oil ring)
3 4

Create a revolution around Vertical sketch axis. The effect should looks similar to real piston :)

Select bottom face (as the above sketch).

External constraints.

The external constraints have been introduced in recent versions of FreeCAD. Now you can create projections of some external geometries (eg. edges) to the sketch and use ones as references. Try find icon with line and blue box Create an edge linked to an external geometry.

Now, create a new sketch on the previously selected face.

Click Create an edge linked to an external geometry and select the biggest circle.
Select face as above. It will be base for a sketch and a revolution.

Hide Revolution using [Space]. You should see the projected circle. It is only reference like construction lines, so you have to draw additional geometry and constrain it with circle. I draw two arcs, and two vertical lines. In other way you can draw circle, two lines and use trimming tool.

Create a 48 mm long pad. Probably it should have reversed direction.

Next operations are similar.

Select face as above.

Create two rectangles. You can use an vertical construction line and symmetry constraint.

Remove material by a 57 mm long pocket.

Now you need some piston pin support. Select bottom piston deck face (as above) and create a new sketch.

Use external constraints tool to make circle projection and hide the Pocket.

Create two symmetrical shapes - every from three lines and arc.

Extrude pad 30 mm long.

Select face as above. It will be base for a sketch and a revolution.

Create two external constraints from vertical edges and hide the Pad001.

Create a geometry using external constraints.

Revolve it and check effects.

Reopen the sketch and add symmetrical geometry.

At the end revolution should look like above.

Select face as above. It will be base for a sketch and a revolution.
Next step is a hole for piston pin. Create a new sketch on he XY plane.

Sketch revolution axes.

You can use every construction line as revolution axis.

Create a geometry with horizontal construction line.

In the revolution dialog select Axis: Sketch axis 0.

After all you still can change construction line position. Adjust vertical distance to -30 (or 30 - depends from the sketch orientation).

Go to the Part workbench and make Revolution002 mirror. Use the YZ plane.

Then select (use [Ctrl]) the Revolution002 and Revolution002 (Mirror #1) and do a boolean fuse.

Next you can select piston solid (probably Revolution001) and fusion from previous step (Fusion). Create a boolean cut (difference) of them.

The piston is almost done.

You can remove some material and create space for rotating crankshaft counterweights. Select side face and create pocket.

I recommend radius 90 mm and distance 162 mm. Model with 105 and 180 mm respectively would be invalid, from manufacturing point of view.

And we have our piston! Let's create some blueprints.

Orthographic views wizard.

Open the Drawing workbench. Multi views creation is now possible.

Create a new Page using Insert new drawing. Select last shape (Pocket001) and use Insert an orthographic projection of a part in the active drawing. You have to define projection type:
  • First angle (Europe),
  • Third angle (United States)
and  views (Top, Left, etc.).

Beside wizard, manual single view creation is possible.

Try add fourth view. Older tutorial should help.

Download file.

Download RAW Video.


Part Design fillets and chamfers work in the same way now.

Select edge or edges and then click on fillet icon.

Radius can be always changed in the the Task view.

If you do not see edge, right-click on a shape and select Appearance... Then change Flat lines to Wireframe.

Fillets are hard for every CAD kernel. They often fail. Create fillets at the end of modelling if you can.

Download file.
FreeCAD 0.13 5391 SVN