简体   繁体   中英

Can I prevent FreeCad from caching Python files?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM