Forum de la communauté Allplan

Pythonparts code using cashed values, instead of the original ones! Really annoying!

Balises:
  • Allplan!

Hi there,
The problem is that the picture is used from memory instead of the original value - picture file TimbWallFrame.png is stored in the same folder as *.pyp file. For stupid reason, I cannot get rid of cashed values.
Please if anyone can help me as it is really annoying as instead of the correct image is shown in dialog box, but all the time the wrong one is shown.

<Parameter>
<Name>WallsX_Img</Name>
<Orientation>Right</Orientation>
<Value>TimbWallFrame.png</Value>
<ValueType>Picture</ValueType>
</Parameter>

Best Regards, Primoz

Hello,

You can delete the file in "__pycache__" folder first.

Or, a trick is to add a special string parameter, not displayed in the palette.
In the code add a line to store in this parameter the current date-time each time the code is executed.
Then, the PythonPart will always be unique and Allplan will not use a previous version stored in the cache.


Deleting the file doesn't help anything.
Can you give me one simple example of special string parameter, not displayed in the palette?

Primoz

See attached file for invisible parameter.
You can use the time or any random value.


Pièces-jointes (1)

Type: image/png
Téléchargé 15 fois
Size: 3,21 KiB

You just added one invisible double parameter - what's the catch? Why would Allplan update the file?
I do not see any time in this attachment, just 0 based double value?

I just show you how to add an invisible parameter in a PythonPart.
I didn't send you the complete code of a PythonPart. I leave you the joy of creating your own functions...
But if that doesn't suit you, forget about the trick I gave you. It does not matter.


How to put date and time into string parameter in *.pyp file I really do not know as there is no such function in Allplan online documentation for creating *.pyp files?

You don't have to put a value in the pyp file.
To assign a value to a parameter, you must to do it in the script in the *.py file.
In "create", you can add something like this (it is a random value between 0 and 360):

build_ele.zUnique.value = random.random() * 360

Of course, you have to import random first (at the beginning of the script with other "import" items):
import random


Thanks!