Can I prevent FreeCad from caching Python files?

136 Views Asked by At

I am trying to learn Python scripting for FreeCad.

In the folder "C:/p/Freecad/0.18/ZillmannTest" I have 2 files:

  • Macro1.py and
  • FCadHelper.py

The content of Macro1.py is as follows:

############
import sys
sys.path.append("C:/p/Freecad/0.18/ZillmannTest")

from FCadHelper import *

helper = FCadHelper()


helper.startDocument('TestKopf')
helper.addBody('TestKopfBody')
helper.addSketch('TestSketch')
####################

I can start Macro1.py from FreeCad Macro menu But when I have an error in FCadHelper.py and correct it, FreeCad does not load the changed file FCadHelper.py, it keeps using the old (chached ?) version of the file. To use the changed file I have to terminate FreeCad and start it again. Which is annoying.

Is there a way to stop FreeCad from caching this file? As I plan to create a Class library of similar files, the problem will then be even greater than now.

Kind regards

1

There are 1 best solutions below

0
On

You can try importlib.reload:

https://docs.python.org/3/library/importlib.html#importlib.reload

It is a little tricky sometimes, but it will work in your case.