FreeCAD Debugging

FreeCAD Debugging

Powerful software programs often have macro programming languages that you can use, and if you know how to program, you probably appreciate them. However, sometimes the program’s built-in debugging facilities are lacking or even nonexistent If it were just the language, that wouldn’t be such a problem, but you can’t just grab a, for example, VBA macro from Microsoft Word and run it in a normal Basic interpreter. Your program will depend on all sorts of facilities provided by Word and its supporting libraries. [CrazyRobMiles] was frustrated with trying to debug Python running inside FreeCAD, so he decided to do something about it.


[Rob’s] simple library, FakeFreeCad, gives enough support that you can run a FreeCAD script in your normal Python development environment. It only provides a rude view of what you are drawing, but it lets you explore the flow of the macro, examine variables, and more.

You can read more about it on the GitHub page, but essentially, you wrap your Python code into a function, import FakeFreeCAD, and then add a little boilerplate code and call the function. Here’s a partial example of a test function:


from FakeFreeCad import * ### code from FreeCad starts here
### Make it into a function that can be called to make the part def makePlate(): plate = Part.makeBox(800,600,100)
hole = Part.makeCylinder(200,200,Base.Vector(400,300,0))
plate = plate.cut(hole) Part.show(plate)
Gui.SendMsgToActiveView("ViewFit")
Gui.activeDocument().activeView().viewAxometric() ### End of the FreeCad code

You’ll have to dig through the code to see how many things are supported, but it would probably be pretty easy to add anything that’s missing. Naturally, having debugging support in FreeCAD would be better, but this is a ..

Support the originator by clicking the read the rest link below.