Hi all,
I'm building a PythonPart interactor that reads road axis data programmatically and exports it to CSV. I've made good progress using NemAll_Python_RoadDTM but hit two specific blockers I'd appreciate help with.
Environment: Allplan 2027, PythonParts SDK
Issue 1: IAxis.serializeJSON() returns garbled Unicode string
I can successfully retrieve the active axis via PAxisManager.getActiveAxis() and call serializeJSON() on it, but the returned Python string contains garbled characters instead of valid JSON.
axis = PAxisManager.getActiveAxis() json_raw = axis.serializeJSON() print(repr(json_raw[:50])) # Output: '≻摩㨢㐢䙅㔲〷ⵁ㜵䙂㐭㈰ⴸ䄸䈱䐭㠰䐷䄳㜸㡃≂∬...'
Checking the ordinal values of each character, each one appears to encode 2 bytes of what should be UTF-8 JSON. I've tried:
- json_raw.encode('latin-1').decode('utf-8')
- Reconstructing bytes via bytes([ord(c) & 0xFF, (ord(c) >> 8 ) & 0xFF]) for each character, then decoding as UTF-8 or UTF-16-LE
All attempts fail with 'utf-8' codec can't decode byte 0xc0 in position 16384' — which appears to be where the C++ string's null terminator padding begins.
The stub for serializeJSON shows it returns std::string from C++ — is there a correct way to decode this in Python? Or is there a different method to get the full axis JSON data in a usable form?
Issue 2: IVerticalAlignment.getElevationAtStation() — double& out-parameter not accessible from Python
def getElevationAtStation(self, station: float, elevation: float,
operateLogicalAlignment: bool) -> bool:
"""bool getElevationAtStation(double station, double& elevation,
bool operateLogicalAlignment)"""
The trace window o/p-
IVerticalAlignment.getElevationAtStation(IVerticalAlignment, float, float, bool)
did not match C++ signature:
getElevationAtStation(..., double station, double {lvalue} elevation, ...)
I also tried ctypes.c_double(0.0) but that also fails with a type mismatch.
Does boost.python wrap this as a tuple return (bool, float) instead? Or is there another pattern for accessing double& out-parameters from this SDK?
What I've successfully achieved so far for context:
- PAxisManager.getActiveAxis() → works, returns valid IAxis
- axis.getHorizontalAlignment() → works, returns IHorizontalAlignment directly (no .get() needed)
- IHorizontalAlignment.getPointAtDistance(distance, XYZPoint(), False) → works perfectly, XYZPoint is mutable so it gets populated in-place
- axis.getStartingStation(False) / axis.getEndingStation(False) → works
- axis.getName(), axis.getId() → work
So mutable object out-parameters work fine (XYZPoint) — only the double& primitive out-parameter pattern and the JSON string encoding are blocking me.
Any help appreciated. Thanks!