icon

Forum Allplan

From existing UVS back to the ClippingPath [Risolto]

Tags:
  • AssocViewAdapter
  • SingleElementSelectResult
  • ClippingPathBody
  • ClippingPath
  • UVS
  • ModelObject

Hello.

I need the geometry information of an existing section.
I'm selecting something (a Macro) in a UVS with a single selection. It's possible to get some information about the UVS (AssocViewAdapter).
But is it also possible to get information about the ClippingPathBody or the ClippingPath (Polyhedron3D preferred)?
I absolutely want to avoid a second selection round.

self.selection_result = SingleElementSelectResult()
self.selection_result.assoc_view
...
missing link
...
section_def_data.ClippingPath()

Thank you,
Christian

Allegati (2)

Type: text/plain
162 scaricato
Size: 8,52 KiB
Type: text/xml
155 scaricato
Size: 662,00 B

Show solution Hide solution

Hi Christian,

I just fount this funtion in one of my projects:

    @staticmethod
    def _find_clipping_box_uuid(uvs: AllplanElementAdapter.AssocViewElementAdapter) -> uuid.UUID:
        """Find the clipping box UUID associated with the given UVS using the associative framework

        Args:
            uvs: UVS element

        Returns:
            UUID of the clipping box
        """
        filter_clipping_path = ElementFilter([AllplanElementAdapter.ClippingPath_TypeUUID])
        uuid_gen = (uuid.UUID(str(ele.GetElementUUID())) for ele
                    in AllplanBaseElements.AssociationService.GetObservedElements(uvs.GetDocument(), uvs.GetElementUUID())
                    if filter_clipping_path(ele))

        return next(uuid_gen, uuid.UUID(int=0))

The function returns the UUID of the AllplanElementAdapter.ClippingPath_TypeUUID object, the UVS (AssocViewAdapter) is associated with. Simply adapt it to get the geometry instead of uuid. The geometry should be the Polyhedron.

Note that GetObservedElements was exposed to Python on some of the recent versions of ALLPLAN. In 2024, the code above probably won't work. It will in 2026, not sure about 2025.

Cheers,
Bart

Hi Christian,

I just fount this funtion in one of my projects:

    @staticmethod
    def _find_clipping_box_uuid(uvs: AllplanElementAdapter.AssocViewElementAdapter) -> uuid.UUID:
        """Find the clipping box UUID associated with the given UVS using the associative framework

        Args:
            uvs: UVS element

        Returns:
            UUID of the clipping box
        """
        filter_clipping_path = ElementFilter([AllplanElementAdapter.ClippingPath_TypeUUID])
        uuid_gen = (uuid.UUID(str(ele.GetElementUUID())) for ele
                    in AllplanBaseElements.AssociationService.GetObservedElements(uvs.GetDocument(), uvs.GetElementUUID())
                    if filter_clipping_path(ele))

        return next(uuid_gen, uuid.UUID(int=0))

The function returns the UUID of the AllplanElementAdapter.ClippingPath_TypeUUID object, the UVS (AssocViewAdapter) is associated with. Simply adapt it to get the geometry instead of uuid. The geometry should be the Polyhedron.

Note that GetObservedElements was exposed to Python on some of the recent versions of ALLPLAN. In 2024, the code above probably won't work. It will in 2026, not sure about 2025.

Cheers,
Bart

Hello Bart,

"AllplanBaseEle.AssociationService.GetObservedElements(uvs.GetDocument(), uvs.GetElementUUID())"
Perfect, that worked. Thank you! I would never have tried that myself.

Bye, Christian