Hello,
My context is this: I have a script with scenes and each scene has a location.
I want to get a status of all occurrences of all locations:
3 scenes occur in Loc A, 2 scenes occur in Loc B…
Currently I do that “manually” by creating one agent per Location:
Agent Loc A = descendedFrom(“/Scenes”)&$MyLocation.contains(“Loc A”);
Agent Loc B = descendedFrom(“/Scenes”)&$MyLocation.contains(“Loc B”);
These agents are in a container so I can plot them or sort their displayValue by childCount.
It is not that painful but I don’t know all of my locations yet and I could need this process for attributes with many more values.
I tried the following code - it does not work and does not feel right as it should first create a Note with the Location Name then link the necessary notes in it.
Then again what would happen to those notes on the next run if, for example, a location were renamed?
This finds the $Name of any scene (and only scenes) whose $Location’s values match the $Name of this location note.
Just as you don’t want 00s of agents, the same applies to rules. Edicts generally run when needed and can be refreshed on demand. as the code above is in the prototype, any new location note gets this edict so there is no configuration to do.
Another approach is to link scenes to all the location(s) they use and get the edict to check for links of the appropriate type and source…
Yes, this is a good approach, but you could also consider leveraging linking, specifically .link operators. This would enable you to populate locations every time you linked them to a scene. Also, once you have the links, you can leverage the hyperbolic view and map view to create visual associations. If this is of any interest, we can explore this angel, but what @mwrw has suggested works great as well.