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] Allplan crashes when creating a parameter


Hello all,

I am trying to create some building elements from within my .py file (interactor). But at some point Allplan keeps crashing.
This is my code:

    def on_control_event(pyp_doc: BuildingElement,
                        event_id: int):
            serv = pyp_doc.palette_service
            palette = serv.palette
            builder = palette.GetPythonWpfPaletteBuilder()
            # reset() does not thrown an error
            builder.Reset()
            # once this add seperator is called, a MemoryException is thrown
            builder.AddSeparator(1, "expander")

While debugging, I do see that everything has the functions I am calling, so this should not be an issue...
Maybe my "expander" string, which I am passing as argument, is wrong, but I don't know what to put there (I am assuming it is a new id?)

Help is very much appreciated!

Hilfreichste Antwort anzeigen Hilfreichste Antwort verbergen

Hello!
I am not sure, what you are trying to achieve. I suppose, by create building elements you mean dynamically create new controls in the palette? The PythonWpfPaletteBuilder is not intended be used directly in the script. The PythonPart framework uses it to create the controls on the palette, based what is defined in .pyp file.

I suppose, you want to add a separator dynamically into the palette, but that is not the way. If you want to dynamically put a separator on a certain place, than it is better to define it in the .pyp file right away, but just set the tag

<Visible>
to False and turn it on from the script as we describe it here.

If you want to insert the separator a couple number of times into the , e.g. after a set of controls, it is better to use a named tuple and include the separator at the end of this tuple, as shown in the linked example.

There is also the AnyValueByType
where you can include any parameter into the palette dynamically, also a separator.

And last but not least, you can create a set of parameters in a separate .pyp file (call it .incpyp or subpyp, or whatever) and include it into your .pyp file with the include parameter. The included .incpyp file can contain any type of controls, also separators, expanders, other namedtuples...

You should choose what's best for your use case. If you feel overwhelmed by the number of options, describe your use-case more precisely and I will try to help you choosing the right solution

Best,
Bart

Hello!
I am not sure, what you are trying to achieve. I suppose, by create building elements you mean dynamically create new controls in the palette? The PythonWpfPaletteBuilder is not intended be used directly in the script. The PythonPart framework uses it to create the controls on the palette, based what is defined in .pyp file.

I suppose, you want to add a separator dynamically into the palette, but that is not the way. If you want to dynamically put a separator on a certain place, than it is better to define it in the .pyp file right away, but just set the tag

<Visible>
to False and turn it on from the script as we describe it here.

If you want to insert the separator a couple number of times into the , e.g. after a set of controls, it is better to use a named tuple and include the separator at the end of this tuple, as shown in the linked example.

There is also the AnyValueByType
where you can include any parameter into the palette dynamically, also a separator.

And last but not least, you can create a set of parameters in a separate .pyp file (call it .incpyp or subpyp, or whatever) and include it into your .pyp file with the include parameter. The included .incpyp file can contain any type of controls, also separators, expanders, other namedtuples...

You should choose what's best for your use case. If you feel overwhelmed by the number of options, describe your use-case more precisely and I will try to help you choosing the right solution

Best,
Bart