Scripting FreeCAD from Rhino: FilletEdge case

I recently started working on a Rhino.Python script that accesses another CAD application / modeling engine via scripting without leaving Rhino’s GUI. The script is an alternative to _FilletEdge for when Open Cascade, via FreeCAD, can solve some constant radius, rolling-ball problems like those reported to the forum and/or are currently listed as Bugs in YouTrack.

I’m using Rhino 7, 7.13.21348.13001 and FreeCAD 0.019.24267 on Windows.

The following are a couple of examples of _FilletEdge vs. FreeCAD’s Part Fillet. Both FreeCAD/OCCT’s solutions include a patch-like surface at intersection of the edges. (Notice the setback fillets in the last GIF. They were not specified.)

FilletEdge_A FilletEdgeFC_A
(Stubborn Corner)

FilletEdge_B FilletEdgeFC_B
(4 Corner fillets)

I’m going to work on the script more before publishing it.

7 Likes

Hi Steve,
Thank you for sharing the progress! Can’t really help you, but your fillet project looks quite interesting.
Do you mind if I ask how is the connection to FreeCAD achieved? Through Rhino.Inside or?

The Rhino.Python script writes out a .py, then subprocesses headless FreeCAD to run it.

1 Like

Thank you @spb ,
So from the Rhino.Python you are directly calling FreeCAD?

He mentioned using the subprocess module to communicate with headless Freecad, which means running it as a command line tool.

1 Like

rhinopython/spb_Brep_filletEdges_in_FreeCAD.py at master · CADacombs/rhinopython · GitHub

The file paths are set for use on Windows. The script and STEP files are created on the current user’s Desktop. Their paths and the path to the headless FreeCAD executable are set immediately after the imports near the beginning of the script.

What file paths can get this working on a Mac?

User input works a little differently than _FilletEdge; pressing the Enter key confirms the choice of the currently selected edges and radius value.

Examples showing variable radius fillets created to connect fillets of different constant radii:
FilletEdgeFC_C FilletEdgeFC_D

I don’t have FreeCAD but line 70 surely needs to be changed to point to the Applications folder, where the FreeCAD binary resides:
sFCcmd_Path = '"{}"'.format(r"/Applications/FreeCAD")

*nix systems (Linux, macOS) also use forward slashes in paths, so you might want to change all of these, for instance:

sPath_Script_for_FC = desktop + r"\to_FC.py"sPath_Script_for_FC = desktop + r"/to_FC.py"

However, you could easily make this more multiplatform compliant, by using os.path.join(path1, path2) instead of adding raw strings.

It would also probably be a good idea to place the FreeCAD file in the same directory as the current Rhino one, instead of dumping everything on the desktop:

os.path.dirname(Rhino.RhinoDoc.ActiveDoc.Path)