icon

Support Forum

[Frage] Bildschirm-Massstab auslesen

Schlagworte:
  • PythonParts
  • GetScreenScale
  • NemAll_Python_IFW_Input
  • ViewWorldProjection
  • GetViewWorldProjection
  • 2025

Hallo zusammen

ich habe ein Standard-PythonPart, in dem ich den Bildschirmmassstab über ViewWorldProjection.GetScreenScale() auslesen möchte.
Der untenstehende Code hat in Allplan 2024 noch funktioniert, in Allplan 2025 erhalte ich jedoch eine Fehlermeldung.

Kennt jemand einen Workaround oder eine alternative Methode, um den Bildschirmmassstab in Allplan 2025 auszulesen?

vp = AllplanIFWInput.InputViewDocumentData.GetViewWorldProjection()
if vp:
    scale = vp.GetScreenScale()

Boost.Python.ArgumentError: Python argument types in
    InputViewDocumentData.GetViewWorldProjection()
did not match C++ signature:
    GetViewWorldProjection(class Allplan::IFW::Input::InputViewDocumentData {lvalue})

Gruss und Dank
Hansruedi

in Allplan 2026 PythonFramework und Examples finde ich nur folgende Verwendung:

view_proj = self.coord_input.GetViewWorldProjection()

Es gibt also scheinbar keine statische Methode GetViewWorldProjection() mehr.
Man braucht dazu ein AllplanIFW.CoordinateInput-Object, welches man scheinbar nur bei einem Interactor-PythonPart bekommt.

Zitiert von: nemo
Es gibt also keine statische Methode GetViewWorldProjection() mehr.
Man braucht dazu ein AllplanIFW.CoordinateInput-Object.

Der unten stehende Code funktioniert grundsätzlich, führt jedoch in einigen Fällen dazu, dass Allplan abstürzt.

coord_input = AllplanIFWInput.CoordinateInput()
vp = coord_input.GetViewWorldProjection()

if vp:
    scale = vp.GetScreenScale()

Es ist nicht sinnvoll, ein solches AllplanIFW.CoordinateInput-Object innerhalb das PythonParts zu instanzieren (zu erzeugen)!
Selbst wenn das möglich ist: Das führt zu den Abstürzen!

Man braucht dazu ein AKTUELLES AllplanIFW.CoordinateInput-Object, welches man nur bei einem Interactor-PythonPart vom Framework "reingereicht" bekommt.

Anhänge (1)

Typ: image/png
17-mal heruntergeladen
Größe: 72,10 KiB

Zitiert von: nemo
... welches man nur bei einem Interactor-PythonPart vom Framework "reingereicht" bekommt.

Danke für die Antwort.
Leider habe ich ein Standard-PythonPart.

Eigentlich hat es mich überrascht, dass das selbst instanziierte AllplanIFWInput.CoordinateInput() überhaupt funktioniert.

Hallo,

Standard PythonPart in ein Script-Object umwandeln. Geht ab ALLPLAN 2025, sogar teilweise ab 2024. ScriptObject hat Zugang zu BaseScriptObjectData
, welches den CoordinateInput-Objekt beinhaltet.

Wie Nemo gesagt, auf gar kein Fall den CoordinateInput selbst zu initialisieren. Der Konstruktor dieser Klasse gehört eigentlich nicht in das API, genauso wie der Konstruktor von DocumentAdapter.

Das Umwandeln ist ein bisschen Aufwand, hält sich aber in Grenzen. Wie man's macht ist hier beschrieben.

Grüße,