Search code examples
anylogic

Include point nodes to a collection using code in Anylogic


I have a grid-like network consisting of paths and point nodes in Anylogic, where the intersection between two paths is a point node. There are 900 point nodes in the network, which are named node1, node2, node3, ..., node900.

Is there any way to include those 900 point nodes into a collection programmatically (using codes)?

I noted that I can select all point nodes and then right-click to create a collection, but I am not sure how to select the point nodes only, without selecting the paths (as the point nodes are located in between paths).


Solution

  • You can do this:

    for(Node o : network.nodes()){
        if(o instanceof PointNode){
            collection.add((PointNode)o);
        }
    }