Persistent Caching Issue with Custom Python Script - PLANTREGISTERCUSTOMSCRIPTS

Persistent Caching Issue with Custom Python Script - PLANTREGISTERCUSTOMSCRIPTS

hyliangRVUBQ
Explorer Explorer
341 Views
7 Replies
Message 1 of 8

Persistent Caching Issue with Custom Python Script - PLANTREGISTERCUSTOMSCRIPTS

hyliangRVUBQ
Explorer
Explorer

Hello everyone,

I'm facing a very frustrating caching issue with a custom Python-based component I've created for AutoCAD Plant 3D, and I've exhausted all the standard solutions. I'm hoping someone here might have encountered a similar problem or can offer a fresh perspective.

The Problem:

I have a custom component whose geometry is defined by a Python script. I register it using the following workflow:

  1. ^C^C(arxload "PnP3DAcpadapter.arx");PLANTREGISTERCUSTOMSCRIPTS;
  2. QUIT and then restart Plant 3D.

This works perfectly for the first version of the script. However, when I modify the Python code (e.g., changing the geometry or dimensions), Plant 3D stubbornly uses the original, cached version of the component. The changes I've made to the script are completely ignored.

What I've Already Tried (and what didn't work):

I have attempted every cache-clearing method I can find, including:

  • Manually deleting all .pyc and .xml files associated with the script (**.pyc, **.xml, ScriptGroup.xml, variants.xml, variants.map).
  • Completely shutting down and restarting AutoCAD Plant 3D.
  • Rebooting the computer.
  • Running the built-in PnPLocalDataCachePurger.exe tool from the PLNT3D directory.
  • Manually deleting the contents of all related cache folders, including:
    • %TEMP%
    • ExternalDataCache

Despite all these efforts, Plant 3D consistently reverts to the initial, cached version of the Python script. It seems there is a deeply embedded or undocumented cache that survives all these actions.

My Question:

Has anyone in this forum encountered this specific issue where PLANTREGISTERCUSTOMSCRIPTS fails to update a Python component after the initial registration? Is there an additional, hidden cache location or a different procedure required to force a complete refresh of a custom scripted component?

Any insights or suggestions would be greatly appreciated. Thanks in advance!

0 Likes
Accepted solutions (2)
342 Views
7 Replies
Replies (7)
Message 2 of 8

h_eger
Mentor
Mentor

@hyliangRVUBQ ,

 

Which version of AutoCAD Plant 3D are you using?
I assume you create and test your Python scripts locally.
Have you checked the "__pycache__" folder to see if the *.pyc file has also changed after changing your Python script and registering it with "PLANTREGISTERCUSTOMSCRIPTS"?


If an error has occurred, the Python script will NOT compile, which would explain the behavior you described.

-

If my reply was helpful, please give a "Kudo" or click the "Accept as Solution" button below (or both).

Hartmut Eger
Senior Engineer
Anlagenplanung + Elektotechnik
XING | LinkedIn

EESignature



0 Likes
Message 3 of 8

hyliangRVUBQ
Explorer
Explorer

Thanks for the detailed responses. To answer the questions raised:

  1. I'm using AutoCAD Plant 3D 2025
  2. Yes, I create and test my Python scripts in a local environment.
  3. I've checked the "__pycache__" folder, and the .pyc file does get updated after I run the "PLANTREGISTERCUSTOMSCRIPTS" command. This confirms the script is compiling without syntax errors.

I've made a short video to demonstrate the issue. In the video, I show that when I modify my original .py script, its 3D model doesn't update and still displays the way it did when it was first registered. To verify this, I copied the same original script to a new test.py and in this case, the updated 3D model displayed correctly.

That's why I think the issue lies in how Plant 3D caches the originally registered script, and I’d really appreciate any further suggestions on how to resolve this.

 

0 Likes
Message 4 of 8

maxpiper
Advocate
Advocate

Have you purged the original scripted object from the drawing?

0 Likes
Message 5 of 8

hyliangRVUBQ
Explorer
Explorer

Yes, in addition to manually clearing the %TEMP% and ExternalDataCache folders, I also make sure to run the PnPLocalCachePurger.exe tool.
However, the issue still persists.

0 Likes
Message 6 of 8

matt.worland
Collaborator
Collaborator
Accepted solution

From my testing, one of the biggest issues when testing scripts is that they are 'cached' in the drawing as a block. As @maxpiper mentioned, erasing that block and purging should fix that type of issue. Or better yet, when you test, start with a brand new drawing every time. The drawing does not need to be in a project, and you can use drawing1 to test your scripts.

 

As far as I know, there are only two places a script is stored: the __pycache__ folder and then as a block in the drawing. I don't think %TEMP% or the ExternalDataCache has anything to do with it. Unfortunately, you do have to close Plant3d every time after running PRCS. I wish Autodesk had a fix for that, as it is a huge time suck when creating Python libraries. According to all of the steps you've mentioned, it sounds like you are doing the steps correctly, but it could be 'cached' in the drawing you test in.

 

I would suggest testing in a blank drawing to see if that helps.

 

 

If my reply was helpful, please give a "Thumbs Up" or "Accept as Solution"
Message 7 of 8

hyliangRVUBQ
Explorer
Explorer
Accepted solution

Hey, matt.worland,

Thank you so much for the detailed explanation! You're absolutely right -- the issue was with the drawing's cache. Your suggestion helped me solve the problem.

I made a short video showing the steps that worked for me. After updating my test.py file and running "PLANTREGISTERCUSTOMSCRIPTS", I had to close Plant 3D and then use the "PURGE" command to remove the cached block from the DWG file.

After that, I was able to generate the file and see the updated changes.

Thanks again for the great advice! This is a huge help.

 

0 Likes
Message 8 of 8

matt.worland
Collaborator
Collaborator

I'm glad that worked for you. Also keep in mind, if you run a script and it fails, it can add an empty block to the drawing, so you can't select it to delete in a normal fashion. You can use the delete option in the Find Non-Purgeable Items page of the purge dialog.

Have fun with your coding,

matt

If my reply was helpful, please give a "Thumbs Up" or "Accept as Solution"
0 Likes