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