icon

Das Wissen aller Anwender nutzen

Im Allplan Connect Forum tauschen sich Anwender aus, geben wertvolle Tipps oder beraten sich bei ganz konkreten Aufgabenstellungen − auch international.
Und damit wirklich keine Frage unbeantwortet bleibt, unterstützen die Mitarbeiter des Technischen Supports ebenfalls aktiv das Forum.

Es erwarten Sie:

  • Foren-Vielfalt aus CAD Architektur, CAD Ingenieurbau uvm.
  • Tipps von User für User
  • international: Deutsch, Englisch, Italienisch, Französisch und Tschechisch

Melden Sie sich jetzt an und diskutieren Sie mit!

Zur Registrierung

[Frage] Variable initializing once [Gelöst]

Schlagworte:
  • PythonParts

Hello,

is there a function for pythonparts thats called only once the element is created?
It should not be called again, when selecting the element.

Thank you.

Lösung anzeigen Lösung verbergen

Hello,

in a standard PythonPart you can use a hidden integer parameter, which you set to 0
in the pyp file. In the py file you can check this 0 value, set the variables and the parameter
value to 1.

In general it's useful to change to a ScriptObject-PythonPart, which has much more functionality.
Here you can get the execution mode like creation, modification, ...

Best regards
Horst

Hi,

which PythonPart type you are using: Standard, ScriptObject, Interactor?

Best regards
Horst

Hello,

it's a standard PythonPart.
I would like to initialize variables once the PythonPart is selected from the library.
The variables should no reset to "default" when being selected.
I'd like to set these variables via code, not via xml.

Best regards

Hello,

in a standard PythonPart you can use a hidden integer parameter, which you set to 0
in the pyp file. In the py file you can check this 0 value, set the variables and the parameter
value to 1.

In general it's useful to change to a ScriptObject-PythonPart, which has much more functionality.
Here you can get the execution mode like creation, modification, ...

Best regards
Horst

Zitiert von: joschwarz
Hello,
it's a standard PythonPart.

I would like to initialize variables once the PythonPart is selected from the library.

The variables should no reset to "default" when being selected.

I'd like to set these variables via code, not via xml.
Best regards

Hi,

as mentioned before, switching to ScriptObject contract is the way to go. This Video can help as well as this diagram

Cheers,
Bart