[Frage] How to handle corrupt geometry with the Python API [Gelöst]


Hello,

I want to apply the NemAll_Python_Geometry.MakeUnion method on two polyhedrons which I retrieved from a fixture. Although they seem to be valid when I test them with Polyhedron3D.IsValid(), the MakeUnion methoud throws an error (eWrongShape) and an empty Polyhedron3D.

When I place the two polyhedrons in the model and try to use the Union tool manually I also get an error ("Solids cannot be modeled"). This is fixed when I apply the "Repair 3D Elements" tool on both elements and then it is possible to Union them both manually and with the API MakeUnion method. Is there a way to repair the polyhedrons with the API? I've tried the Heal() and Normalize() methods but they don't seem to have an effect. I realy would like to handle the 'corrupt' polyhedrons inside the API, is that possible somehow?

I've attached the data to this topic (Export Loaded drawing files with resources) and I've modified the GeometrySelectInteractor.py example to show the case. Output of trace, generated with the modified GeometrySelectInteractor is also attached.

Attached data is from Allplan 2025 WIP-2.

http://www.cadblanche.eu

Anhänge (3)

Typ: application/zip
402-mal heruntergeladen
Größe: 3,41 KiB
Typ: application/zip
394-mal heruntergeladen
Größe: 1,69 KiB
Typ: image/png
28-mal heruntergeladen
Größe: 53,63 KiB

Lösung anzeigen Lösung verbergen

Zitiert von: SanderP
Thanks for your reply! I will try to find a workaround and keep an eye on the release notes.

Hello Sander,

I am happy to inform you, that the methods for repairing a corrupted polyhedron geometry are now available in the API inside the PolyhedronUtil class. This is the case for the version 2025-WIP-5 subsequent ones. If you are participating the WIP program, you are able to download the 2025-WIP-5 from today on on the Allplan connect. Otherwise, you will have access to this functionality in Allplan 2025 with its release in October.

The problem with the geometry you posted were the normal vectors: apparently not all the face normal vectors were pointing to the inside of the solid.

Best,
Bart

Hello Sander,

If polyhedron faces are non-planar, Heal tries to fix it - either by moving the vertices a little to make them planar, or by triangulating the faces around the "fixed" vertices. Apparently, this is not the issue with your polyhedron.

The repairing the polyhedron with the UI function "Repair" involves 4 steps:

  • Repairing Cross Loop Faces
  • Spliting Faces At Edges
  • Splitting Non Planar Faces (Basically what heal does)
  • Repairing Face Normals
These steps are performed by internal functions, which are not yet exposed to python API. But we plan to do that in the nearest future. Hopefully in Allpllan 2025, but I cannot guarantee anything here.

Best,
Bart

Thanks for your reply! I will try to find a workaround and keep an eye on the release notes.

http://www.cadblanche.eu

Zitiert von: SanderP
Thanks for your reply! I will try to find a workaround and keep an eye on the release notes.

Hello Sander,

I am happy to inform you, that the methods for repairing a corrupted polyhedron geometry are now available in the API inside the PolyhedronUtil class. This is the case for the version 2025-WIP-5 subsequent ones. If you are participating the WIP program, you are able to download the 2025-WIP-5 from today on on the Allplan connect. Otherwise, you will have access to this functionality in Allplan 2025 with its release in October.

The problem with the geometry you posted were the normal vectors: apparently not all the face normal vectors were pointing to the inside of the solid.

Best,
Bart