Friday, 12 September 2025

Removing parts of a STEP file in FreeCAD

My first baby steps with FreeCAD for editing step files, the comparatively easy challenge of removing some block-like shapes in a 3D-printed keyboard case. The motivation here is making room for a battery & reset button for a Bluetooth variant of what was a USB wired-only keyboard. Getting started with FreeCAD is hard!

Before screenshot of keyboard case in FreeCAD
Before - note the bracing beams

After screenshot of keyboard case in FreeCAD
After - now with lots of open space

Selecting Faces

Given a STEP file, it was surprisingly hard to get FreeCAD to let me even select faces. By analogy with presentation software, all the bits are grouped so you have to ungroup everything first. So the first challenge, opening a STEP file and getting to the point of being able to select individual faces. 

  1. Install and open FreeCAD, I used v1.0.2 on macOS ARM.
  2. Download this version of the Gamma Omega keyboard top case.
  3. Start FreeCAD.
  4. Open STEP file using menu "File", "Open...", select the "top.step" file, "Open".
  5. At the import prompt (not sure what is best):
    ☑ Enable STEP Compound merge
    ☐ Use LinkGroup
    ☐ Import invisible objects
    ☐ Reduce number of objects
    ☑ Expand compound shape
    ☑ Show progress bar while importing
    ☐ Ignore instance names
    ☐ CodePage: No conversion
    ☐ Mode: Single document
    ☐ Don't show this dialog again
  6. In the model pane (on left), get "Unnamed" document containing "FusionCompound". 
  7. Switch to "Part" workbench (via toolbar)
  8. Select the "FusionCompound" (via model list), all the case goes green in the main area.
  9. Go to menu "Part", "Compound", select "Explode compound".
  10. In the model pane, "Unnamed" document now contains "FusionComponent.0" (visible with the eye icon), which contains "FusionComponent" (invisible with crossed out eye icon).
  11. Select "FusionComponent.0" in the model list.
  12. Again, go to menu "Part", "Compound", select "Explode compound". Hat tip to this blog post for the hint to try again.
  13. This takes a little longer. Now in the model pane, "Unnamed" document contains "Exploded FusionComponent.0" (visible with the eye icon), which contains "FusionComponent.0.0" (flat underside at bottom front right) to "FusionComponent.0.619" (flat underside at bottom front left).
  14. Click on bits of the model, eg the sunken letter Gamma in the centre top of the case is "FusionComponent.0.361".

Deleting faces

Onto the next stage, removing bits. I want to remove three faces which make up a "bracing beam" so that I can later add a hole for a reset button, and a new brace futher over.

  1. Make sure the "Parts" workbench is still active.
  2. Spin the model about with the mouse (I found the Blender control mode a little easier), find the target "bracing beam". 
  3. Click on the inner-most side wall so it alone goes green. Should see "FusionComponent.0.85" selected in the model pane.
    Screenshot from FreeCAD v1.0.2 showing part of a keyboard case
  4. Press backspace. The green face vanishes, as does the model tree entry. You can now see inside the once solid wall down to the bottom layer.
    Screenshot from FreeCAD v1.0.2 showing part of a keyboard case
  5. Click on the top of the "bracing beam" and delete that ("FusionComponent.0.87") too:
    Screenshot from FreeCAD v1.0.2 showing part of a keyboard case

  6. Finally click on the third wall and delete that ("FusionComponent.0.86"):
    Screenshot from FreeCAD v1.0.2 showing part of a keyboard case
  7. There is now a hole with three faces to fill - you can see though to the lower floor (the top of the case):
    Screenshot from FreeCAD v1.0.2 showing part of a keyboard case

Repairing the hole

For 3D printing the STEP file we will need to repair the hole left by removing those faces - happily just three flat faces are needed (or equivalently, editing three faces with holes in them - but I haven't managed that yet).

We will be using the "Create ruled surface" tool which is part of the "Parts" workbench. This appears in the "Part" menu about three-quarters of the way down:

FreeCAD v1.0.2 screenshot of the "Part" menu.

The icon for the FreeCAD Part Workbench "Create ruled surface" tool is a blue rectangular plane bounded on the left and right by red edges. You can also find it within the Parts tool bar along with other red-and-blue icons (this can be dragged away from the default to ribbon, mine is currently on the left - and I set the larger icon size in the preferences):

Screenshot of part of the FreeCAD v1.0.2 parts workbench toolbar  

We will also be using the "Draft" workbench "Upgrade" tool as a combined join/fuse/compound/refine to turn out new patches and the surrounding planar face into a single planar face. This is under the main menu "Modification", "Upgrade (U, P)":

FreeCAD v1.0.2 screenshot of the "Modification" menu.
 

The icon for the FreeCAD Draft Workbench "Upgrade" tool is a blue up arrow. You can also find it within the Draft tool bars, along with other blue icons:

Screenshot of part of the FreeCAD v1.0.2 Draft workbench toolbar

With that out the way, this is the simplest way I have found to fill the gaps left by removing those faces:

  1. In the main pane click on the left edge of the hole in the outer wall.
  2. Now command+click on the right edge of the hole in the outer wall.
  3. You should now have the two edges selected in green: 

  4. Check you are in the "Part" workbench.
  5. With the two edges selected, click on the "Create ruled surface" tool icon, or go to menu "Part", "Create ruled surface".
  6. The gap in the wall is filled (the two edges are still selected):
  7. Change to the "Draft" workbench.
  8. Click on the inner wall, command+click on the patch we just made:

  9. Go to menu "Modification", "Upgrade (U, P)" (or click the icon in the tool bar).
  10. Again, go to menu "Modification", "Upgrade (U, P)" (or click the icon in the tool bar).
  11. Now the two planar faces have merged/fused into a single planar face named "Union" in the model tree:

  12. Repeat for the hole in the other wall, giving an autonamed "Union001" entry.
  13. Repeat for the hole in the floor/roof (merging three faces this time), giving a "Union002" entry.

By adding those three planar faces we have repaired the 3D structure.

Getting to that fairly simple set of steps was a struggle. I think my mistake was starting in the "Part" workbench where I tried various things like "Part", "Boolean", "Union" (giving a scary pop-up, "The use of non-solids for boolean operations may lead to unexpected results. Do you want to continue? (No/Yes)", but it seems to have no effect). Also "Part", "Join", "Connect objects" would make a "Fusion" entry which could then be upgraded - but was just a roundabout version of the above.

I removed a few more braces the same way. For the most complex repair it took a few goes to find an order in repairing the faces that worked out.

Verification

  1. Select the "Part" workbench.
  2. Press command+a to select all the parts.
  3. Go to "Part", "Check Geometry".
  4. Click "Run check".
  5. Hopefully "619 processed out of 619 selected. 0 invalid shapes".
  6. Click "Close". 

Saving a new STEP file

I first saved it as "top-no-brace.FCStd" for subsequent work in FreeCAD, and then attemped to export as a new STEP file - only for ghosts of the deleted parts to return: 

  1. With nothing selected, go to menu "File", "Export".
  2. Error pops up "Select the objects to export before choosing Export". 
  3. Press command+a to select all (everying in the main panel should go green; this apparently is not the expected route).
  4. Goto menu "File", "Export".
  5. Pick "STEP with colors (*.step, *.stp)", give it a name like "top-no-brace.step", and click "Save".
  6. On the options popup, I went for:
    ☑ Write out curves in parametric space of surface
    ☐ Export invisible objects
    ☐ Export singel object placement
    ☐ Use legacy export funciton
    Units for export of STEP: Millimeter
    Scheme: AP214 Internation standard
    ☐ Don't show this dialog again
    Close FreeCAD
  7. Close FreeCAD
  8. Open FreeCAD
  9. Open the  "top-no-brace.step", spin the model round to see the back.
  10. Sigh as the deleted braces are back! 

It seems this FreeCAD FAQ covers the problem:

Q. I exported my model to STL or DXF but all the holes are filled up and fillets are missing.
A. Don't select All or use Ctrl + A to export for 3D printing. You typically only need to select the last object at the bottom of the Model tree, or in the case of a PartDesign Body, select the Body itself. 

Sigh. I don't have a single last object, so in the Model tree selected all the remaining "FusionComponent.0.0" to "FusionComponent.0.619" and all the union entries (which visually was the same in the main view). Then it worked. I'm guessing some sort of explicit grouping ought be used - and the following worked:

  1. With nothing selected, click on the yellow block-step "Create part" icon.
    Screenshot of part of the FreeCAD v1.0.2 toolbar

  2. Go to the bottom of the Model pane, see there is now a yellow part entry.
  3. Rename this to "TopCase". 
  4. In the Model pane, drag "FusionComponent.0" (which brings its ~600 children too) into the part.
  5. Drag all the "Union" entries into the part.
  6. Save as "top-no-brace2.FCStd" for subsequent work in FreeCAD
  7. Select the "TopCase" part in the Model pane.
  8. Everything in the main panel should go green. 
  9. Goto menu "File", "Export".
  10. Pick "STEP with colors (*.step, *.stp)", the suggested name of "top-no-brace2-TopCase.step" was fine, click "Save".
  11. On the options popup, I went for:
    ☑ Write out curves in parametric space of surface
    ☐ Export invisible objects
    ☐ Export singel object placement
    ☐ Use legacy export funciton
    Units for export of STEP: Millimeter
    Scheme: AP214 Internation standard
    ☐ Don't show this dialog again
  12. Quit FreeCAD
  13. Open FreeCAD
  14. Open the  "top-no-brace2-TopCase.step", spin the model round to see the back.
  15. Sigh in relief after confirming the deleted bits are gone!

All in all, rather fiddly but fairly easy once you know how to do this. And there is probably an easier way? It would also be good to know why the STEP file tripled in size. Next, I want to rebuild the braces in a slightly different location...

Update

Over on Mastodon, JMC suggested a quicker alternative workflow (thank you!) using a sketch on the xy plane (anchored to the beam's flat face). This uses the "project geometry" tool to mark bits of the model to then be used to draw a closed loop polyline in just the right place. Finally you can extruding/pocket this back 5mm to remove the unwanted region. I'll try to spell that out step by step later.

No comments:

Post a Comment