Support Forum

PythonParts in Double Walls

Schlagworte:
  • Allplan
  • 2025
  • Double
  • Walls
  • PythonParts

Hello,

I am a newbie in the PythonPart field.
I am interested in the integration with precast elements, particularly double walls.
I completed the e-learning course, but it only covers architectural elements.
I searched the PythonParts example directory and did not find any double wall examples, and I also looked through the forum without success.

Does anyone have a PythonPart that interacts with a double wall, such as rebar or something similar?

I would like to know if I can maintain the same pattern as I learned in the course.
For instance, the line "wall_element = AllplanBaseElements.GetElement(selected_wall)" does not work if selected_wall is of type AllplanElementAdapter.PrecastDoubleWall_TypeUUID.

Thanks in advance!
Gaël

Hilfreichste Antwort anzeigen Hilfreichste Antwort verbergen

Hi Gaël,

so what I understand, what you try to do is to place your rebar PythonPart correctly in a double wall. To accomplish this, you have to analyze the geometry of both: architectural wall and the precast double wall.

Both architectural wall and precast double wall are represented in the drawing file as separate elements of different type, what you have already noticed. All these adapters have parent-child relationships to each other. Meaning that having one (e.g. the architectural wall) you can get the other by exploring the hierarchy tree with GetParentElement or GetChildElements.

I think, the good starting point would be to start from the architectural wall. Then you can go down the hierarchy and eventually access the precast layer type. You cannot call GetElements on it, but you can call GetGeometry, which will give you the polyhedron representing the precast double wall layer.

I wrote a script, that shows the hierarchy of the element adapters (see attachment). You select an element in the model and the entire hierarchy is shown in the trace (together with the type of the geometry, this element adapter has). This will help you understand the hierarchy. Here's what I got after selecting an architectural wall:

Tree                                                                            |  Geometry type
--------------------------------------------------------------------------------|------------------------------
Wall_TypeUUID                                                                   |  NoneType
├── AttributeContainer_TypeUUID                                                 |  NoneType
└── WallTier_TypeUUID                                                           |  Polygon2D
    ├── AttributeContainer_TypeUUID                                             |  NoneType
    ├── WallAxis_TypeUUID                                                       |  NoneType
    │   └── WallAxisLine_TypeUUID                                               |  Line2D
    └── PrecastDesign_TypeUUID                                                  |  NoneType
        ├── PrecastVisibleSideSymbol_TypeUUID                                   |  NoneType
        └── PrecastElementDoubleWall_TypeUUID                                   |  Polyline2D
            ├── PrecastLayer_TypeUUID                                           |  Polyline2D
            │   └── PrecastLayer_TypeUUID                                       |  Polyhedron3D
            ├── PrecastLayer_TypeUUID                                           |  Polyline2D
            │   └── PrecastLayer_TypeUUID                                       |  Polyhedron3D
            ├── PrecastLayer_TypeUUID                                           |  Polyline2D
            │   └── PrecastLayer_TypeUUID                                       |  Polyhedron3D
            ├── TextBlock_TypeUUID                                              |  Polygon2D
            ├── PrecastText_TypeUUID                                            |  NoneType
            │   └── TextBlock_TypeUUID                                          |  Polygon2D
            └── TextBlock_TypeUUID                                              |  Polygon2D

I cannot help you analyze the geometry, because it is hard for me to imagine, how does your rebar PythonPart looks like. If you could attach some images, maybe I could give more hints.

IMPORTANT: to run the script, you need to install a Python site-package anytree. Here are the instructions on how to do it.

Best,
Bart

Anhänge (1)

Typ: application/zip
6-mal heruntergeladen
Größe: 2,94 KiB

Zitiert von: KOGA_
... I would like to know if I can maintain the same pattern as I learned in the course.
For instance, the line "wall_element = AllplanBaseElements.GetElement(selected_wall)" does not work if selected_wall is of type AllplanElementAdapter.PrecastDoubleWall_TypeUUID.

Hi Gaël,

the pattern shown in the online course is in detail described in this article (the reading part) and in this article (the modification part) in the online documentation. And important to know here is: this implementation is not yet possible for all kind of Allplan elements. For Precast elements, for example, it is not the case at the moment. Which means, that using Python API you cannot get the python object PrecastElement from an existing Precast elements, double walls, etc.

What you can do, is create a new precast element. But bare in mind: only Precast Element, not a precast slab or a precast wall.

But we are constantly improving the interface so for us it would be interesting to know, what is your ultimate goal? What kind of task would you like to accomplish? Maybe it is possible to achieve this without accessing the PrecastElement object. And if not, maybe we can extend the interface to do so?

Best,
Bart

Hi Bart,

Thank you for answering my question, even if it obstructs the way I planned my Pythonparts ideas.

I'd like to place my already-made rebar Pythonpart into a double wall, but to do that, I can select either the architectural element or the precast one (according to the Python code filter).

Imagine an architectural wall with its two double wall elements.

In the first case — the only working one, IMO — my rebar Pythonpart is placed horizontally into the architectural element. In terms of precast, it starts from the left precast wall and extends throughout the architectural element. You get all the rebar compound in the left precast wall (according to the element plan), and nothing in the right.

Instead of doing that, I tried to place my Pythonpart in the precast element, and... I sent this thread.

I wonder if I can modify this Pythonpart to be cut by the precast wall dividing function. What do you think?

Do you have any other ideas?

Thanks,
Gaël

Hi Gaël,

so what I understand, what you try to do is to place your rebar PythonPart correctly in a double wall. To accomplish this, you have to analyze the geometry of both: architectural wall and the precast double wall.

Both architectural wall and precast double wall are represented in the drawing file as separate elements of different type, what you have already noticed. All these adapters have parent-child relationships to each other. Meaning that having one (e.g. the architectural wall) you can get the other by exploring the hierarchy tree with GetParentElement or GetChildElements.

I think, the good starting point would be to start from the architectural wall. Then you can go down the hierarchy and eventually access the precast layer type. You cannot call GetElements on it, but you can call GetGeometry, which will give you the polyhedron representing the precast double wall layer.

I wrote a script, that shows the hierarchy of the element adapters (see attachment). You select an element in the model and the entire hierarchy is shown in the trace (together with the type of the geometry, this element adapter has). This will help you understand the hierarchy. Here's what I got after selecting an architectural wall:

Tree                                                                            |  Geometry type
--------------------------------------------------------------------------------|------------------------------
Wall_TypeUUID                                                                   |  NoneType
├── AttributeContainer_TypeUUID                                                 |  NoneType
└── WallTier_TypeUUID                                                           |  Polygon2D
    ├── AttributeContainer_TypeUUID                                             |  NoneType
    ├── WallAxis_TypeUUID                                                       |  NoneType
    │   └── WallAxisLine_TypeUUID                                               |  Line2D
    └── PrecastDesign_TypeUUID                                                  |  NoneType
        ├── PrecastVisibleSideSymbol_TypeUUID                                   |  NoneType
        └── PrecastElementDoubleWall_TypeUUID                                   |  Polyline2D
            ├── PrecastLayer_TypeUUID                                           |  Polyline2D
            │   └── PrecastLayer_TypeUUID                                       |  Polyhedron3D
            ├── PrecastLayer_TypeUUID                                           |  Polyline2D
            │   └── PrecastLayer_TypeUUID                                       |  Polyhedron3D
            ├── PrecastLayer_TypeUUID                                           |  Polyline2D
            │   └── PrecastLayer_TypeUUID                                       |  Polyhedron3D
            ├── TextBlock_TypeUUID                                              |  Polygon2D
            ├── PrecastText_TypeUUID                                            |  NoneType
            │   └── TextBlock_TypeUUID                                          |  Polygon2D
            └── TextBlock_TypeUUID                                              |  Polygon2D

I cannot help you analyze the geometry, because it is hard for me to imagine, how does your rebar PythonPart looks like. If you could attach some images, maybe I could give more hints.

IMPORTANT: to run the script, you need to install a Python site-package anytree. Here are the instructions on how to do it.

Best,
Bart

Anhänge (1)

Typ: application/zip
6-mal heruntergeladen
Größe: 2,94 KiB

Hi Bart,

Nice and useful script, thanks.
I'll review your advice, and will somehow get back to this thread.

Appreciate it!
Gaël

Hi Bart,

I'm stuck in my code where I want to implement what you told me. I'd appreciate any help.

I want to get the child elements from an architectural wall.
I filtered the selection input with "WallTier_TypeUUID" type and obtained one wall. This wall is divided into two double walls, which is my goal.

I tried all the Get methods from " BaseElementAdapterChildElementsService" class.

For instance :

dw_elements1 = AllplanElementAdapter.BaseElementAdapterChildElementsService.GetChildElements(selected_wall, True)

-> where selected_wall is a BaseElementAdapter instance

I got :
ATTRIBUT_SPEICHER_19ER
Axe_élément
Calepinage d'un mur
Couche de mur droit
Couche de mur droit
Couche de mur droit
Couche de mur droit
Couche de mur droit

However, I expected too see the structure as shown by your anytree script :
WallTier_TypeUUID
├── AttributeContainer_TypeUUID
├── WallAxis_TypeUUID
├── PrecastWallManagerElement_TypeUUID

│ ├── PrecastDoubleWall_TypeUUID

In this structure, WallTier_UUID is the parent, and PrecastWallManagerElement_TypeUUID is the direct child I aimed to retrieve.

Since this wasn't explicit for me, I searched for a code snippet or an example and found this method from GeometryUtils.py .

def get_child_element(self,
                     parent_element: AllplanElementAdapter.BaseElementAdapter,
                      *valid_type) -> AllplanElementAdapter.BaseElementAdapterList:
        """Get all child element from parent_element

        Args:
            parent_element (AllplanElementAdapter.BaseElementAdapter): Could be a wall
            valid_type (AllplanElementAdapter.ElementAdapterType): element's uuid type for filter purpose

        Returns:
            AllplanElementAdapter.BaseElementAdapterList: list of child element like: openings, layers
        """
        child_elements = AllplanElementAdapter.BaseElementAdapterChildElementsService.GetChildModelElementsFromTree(parent_element)

        if valid_type:
            valid_child = AllplanElementAdapter.BaseElementAdapterList()
            [valid_child.append(child) for child in child_elements if child in valid_type]
            return valid_child

        return child_elements

Even w/ this :

dw_elements = self.get_child_element(selected_wall, [AllplanElementAdapter.PrecastWallManagerElement_TypeUUID])

which is literaly the child element TypeUUID I'm looking for, I didn't get any results.

What did I missed ? Is there a cast I didn't make somewhere?

Thanks in advance,
Gaël

Hi Gaël,

before I assist you further, can you please upload here the drawing file with the wall you want to inspect? Ideally, with as few elements as possible. That would make things a bit easier for me.

Best,
Bart