List all child feature ids of a MoMa Node — GSTPy documentation

# List all child feature ids of a MoMa Node

For this example we show how to get a list of all child feature ids of a MoMa node.

Lets assume our current MoMa tree looks like the following.

And we have two feature classes like the following.

Feature class innercity.

id | name
--- | ---
1 | innercity_feature_1
2 | innercity_feature_2
3 | innercity_feature_3

Feature class area1.

id | name
--- | ---
12 | area1_feature_1
13 | area1_feature_2
14 | area1_feature_3

We want to get a list of the feature ids belonging to the node Augsburg.

Full code sample

    import GSTPy

    owner = ni.get_current_gst_user()
    elements = ni.list_elements(owner)

    model_links = ni.list_children()

    augsburg_element = next((element for element in elements if element.label == "Augsburg"))
    augsburg_link = next(
        (link for link in model_links
         if link.target_id == augsburg_element.id and
         link.target_type == GSTPy.LinkAdjacencyTargetType.Element))

    feature_ids = ni.list_feature_ids_of_link(augsburg_link)

With the example above we can expect the return value as follows. (The order can be different).

    >>> print feature_ids
    [1, 2, 3, 14, 13, 12]