icon

[Frage] How to alway launch latest version of .pyp file

Schlagworte:
  • Cache
  • Opening
  • Always
  • Latest
  • Version
  • Of.pyp
  • File

Hi,

I am having a problem with loading the latest version of Python Parts into Allplan. It only works the first time after launching Allplan. It seems that ALlplan stores .pyp and .py files somewhere in a chache directory that I cannot access or modify easily. I have noticed that even when I run the latest version of my code, Allplan still opens an older one, probably from the cache. Currently, the only way I can solve this is by restarting Allplan or renaming the .pyp file. However, neither of this solutions are pratical.

Could anyone suggest a better solutions? I would like to be able to open my Python Parts by dragging the .pyp file into Allplan window and always have Allplan run the latest version.

Thank you in advice.

Best regards

Hello,

It is possible to add a variable defined with a random number that is refreshed with every execution. This ensures that each element is unique and that Allplan does not reuse a previous version from the cache.


Hi,

I think what daviscio is referring to is how Python in ALLPLAN works.

When you run a python script with a regular python interpreter, like:

python.exe my_script.py
You are always start a new python process and after the script is finished, the process is finished and the memory is released.

This is not the case in ALLPLAN. ALLPLAN starts python interpreter and this interpreter lives within ALLPLAN until you close it.
Python loads modules (.py files) in a "lazy" way - when it sees "import ..." statement, it looks it up and loads it and stores in the memory. The next time this module is needed, python loads it from the memory. This is good - loading from memory is much faster than from hard drive.

When you are the user, you are not changing the code. When you are developing, you want python to reload the module from hard drive each time. This is what reloader does. Please install the PythonParts SDK - it installs the reloader as well.

Please note, that reloader may cause issues: e.g. from my experience, numpy libraries do not like to be reloaded.

ALLPLAN expects the reloder.py to be available under:

...\Usr\{your_username}\PythonPartsScripts\allplan_gmbh\pythonparts_sdk\reloader.py
. If the file is there, reloader will work. Hence, you can deactivate it temporarily by changing the file's name and restarting ALLPLAN.

Best regards,
Bart