Search code examples
rulebooggie

How can I add a node type to the graph from within a script in booggie 2?


Is there are way to access the metamodel, instantiate a node or edge of a specific type and add it to the graph in a script?

Please note: The booggie-project does not exist anymore but led to the development of Soley Studio which covers the same functionality.


Solution

  • Yes, you can get the node/edges types from the metamodel using

    graph.Model.NodeModel.GetType("MyNodeType")
    
    • or -
    graph.Model.EdgeModel.GetType("MyEdgeType")
    

    Using the method graph.AddNode you can add it to the graph and the added node is returned to which attribute assignments can be made.

    All together, it looks like this:

        newNode = graph.AddNode(graph.Model.NodeModel.GetType("MyNodeType"))
        newNode.myAttribute = 42