Search code examples
tostringtext-extractionanylogic

In Anylogic how do you extract the name of an object so i can use and assign it as a Text value? (Object >> Text)


The Problem: An agent has a parameter that refers to an object (lets say an INode). I want to get and use the name of that INode as plain text without writing a function that maps INodes to their names. If currentLocation (which has a value of Node12) is the parameter, in a snippet, it looks like:

agent.currentLocation

Is there a name property of Parameters or other Objects that i can reference and it returns a String (just the text "Node12" in this case)? I have tried all kinds of references with parameter.name, getValue, etc, to no avail.


Solution

  • For INodes you can use myNode.getName(), as you can for every object in Java.

    However, you cannot get the name of parameters, variables, etc. And you shouldn't do that, it is considered bad practice :-)