I ran into the problem today where I had a token with an "item" label, that references an object in the model.
I also had an Operator resource with a direct reference and multiplicity, so no Group. I wanted to create a "distance" field on the Resource, to determine the distance from puller.item (instead of puller) to the operator. However, the code assumes that the physical object is the puller, and when acquiring a resource I cannot specify another puller, so I ended up rewriting the default code to the below, which gives me a nice popup straight in the List window.
Perhaps it is a simple but useful extension if some of the pre-defined options supported this (either with the simple popup or a more complex popup where I can also enter "Label: item")
- treenode value = param(1);
- treenode puller = param(2);
- treenode entry = param(3);
- double pushTime = param(4);
- /**First Travel Destination of Task Sequence */
- treenode taskSequence = /**/puller/**/;
- /**\n Or Travel Distance to */
- treenode travelDistanceToDirect = /**/getlabel(puller, "item")/**/;
- if (!objectexists(puller))
- return GLOBAL_UNREACHABLE;
- treenode destObject = NULL;
- if (isclasstype(puller, "TaskSequence")) {
- int travelTask = findmatch(getnroftasks(taskSequence), gettasktype(taskSequence, count) == TASKTYPE_TRAVEL);
- if (travelTask) {
- destObject = gettaskinvolved(taskSequence, travelTask, 1);
- }
- } else {
- updatelocations(travelDistanceToDirect);
- destObject = travelDistanceToDirect;
- }
- if (objectexists(destObject)) {
- updatelocations(value);
- return distancetotravel(value, destObject);
- }
- return GLOBAL_UNREACHABLE;