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

Naive Approach - Remove faces & fill gaps

This how I solved this myself after a bit of FreeCAD searching & tutorial watching, a reductionist approach of selecting and removing the unwanted elements. 

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...

Expert Approach - Extrude/Pocket

Over on Mastodon, after I published the above, JMC suggested a quicker alternative workflow (thank you!) using a sketch in 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.

Actually following his outline solution (even with the helpful screenshots) took me a bit longer, with hidden assumptions like needing to define a "body", but I could do it: 

  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. Select the model and spin it round to see the underside (eg via the cube top right).
  8. With the "FusionCompound" selected in the "Sketcher" workbench, go to menu "Sketch", "Create sketch" - or from the toolbar:
    Screenshot of part of the FreeCAD v1.0.2 toolbar

  9. When prompted "Select the method to attach this sketch to selected object" pick "Plane face" (I am unsure when that is offered vs "XY plane" etc).
  10. Zoom into the beam to be removed.
  11. Go to menu "Sketcher", "Sketcher tools", "Create external geometry (G, X)" - or use the tool bar icon:
    Screenshot of part of the FreeCAD v1.0.2 toolbar
     
  12. Click on the two edges making up the beam (or the four corners), you can't select the face. They will get a dotted pink line:
  13. Go to menu "Sketch", "Sketcher geometries", "Create polyline (G, M)", or use the toolbar icon:
    Screenshot of part of the FreeCAD v1.0.2 toolbar

  14. Click on the four corners in turn (the icon changes to a cross at the end of the pink lines indicating locking on to the external point of reference), and back to the start to close the loop. It should now have a green outline:
  15. The task pane should say it is "Fully constrained". Click close.
  16. The Model pane should now have under "Unnamed" both "FusionComponent" and then "Sketch" (both visible with the eye icon).
  17. To pre-empt a "Active Body Required" message from the "Pocket" tool, change to the "Part Design" workbench and go to menu "Part design", "Create body" (first entry),or find the blue "Create body" tool:
     
  18. In the Model pane, drag the "FusionComponent" into the new "Body" - creating a "BaseFeature" and hiding the original.
  19. Drag the sketch into the body too.
  20. Select the "Sketch" (so it has a blue background in the model tree).
  21. Go to menu "Part Design", "Create a subtractive feature", "Pocket" - or click this on the toolbar:
    Screenshot of part of the FreeCAD v1.0.2 toolbar
     
  22. It will default to 5mm here, just right to flatten the part we outlined in the sketch flush with the background. Confirm by zooming in and adjusting the view that the beam has been erased.
  23. Double check by using 4mm, and see a stub:

  24. Go back to 5mm, and click OK.
  25. The "Sketch" entry in the Model tree is now a "Pocket" entry, reflecting the last action on the model.
  26. Repeat the sketch & pocket for the other bits
  27. Save as "top-no-brace3.FCStd" for subsequent work in FreeCAD
  28. Goto menu "File", "Export".
  29. Pick "STEP with colors (*.step, *.stp)", the suggested name of "top-no-brace3-BodyPocket001.step" was fine, click "Save".
  30. 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
  31. Quit FreeCAD
  32. Open FreeCAD
  33. Open the "top-no-brace3-BodyPocket001.step", spin the model round to see the back.
  34. Sigh in relief after confirming the deleted bits are gone!

Interestingly this approach the output STEP file is only twice the original's size (much smaller than my approach). It was also much easier/quicker for removing the more complex bracing in the case (see JMC's screenshots), and more importantly the inverse of "Pocket" is the "Extrude" operation which is used to additively build up a 3D model. That is exactly what I would need to do next to rebuild the bracing beams further over.

No comments:

Post a Comment