How to automatically load a milestone collector with a processflow?

How to automatically load a milestone collector with a processflow?

guiroehe
Collaborator Collaborator
652 Views
12 Replies
Message 1 of 13

How to automatically load a milestone collector with a processflow?

guiroehe
Collaborator
Collaborator

[ FlexSim 25.0.2 ]

Hello,

I noticed that even if milestone collectors are added to a flow, if the flow is in a library, the milestone collector (and the links) are lost when the flow is instantiated. Foe example, for an object process flow, if the object is dragged, the flow is dragged, but any milestone connections are empty in the flow. Is there a way to automate this so a pre-configured collector can be brought in automatically?

Thank you.

0 Likes
Accepted solutions (1)
653 Views
12 Replies
Replies (12)
Message 2 of 13

moehlmann_fe
Enthusiast
Enthusiast
Accepted solution

You can add an Object node to the user library and place both the Process Flow and the collector as its subnodes. Then you write a dropscript that copies the collector to the model (possibly after checking if it already exists), adds the Process Flow and finally creates links between all milestone activities in the flow and the collector.

An example library is attached.

milestone_lib_test.fsl

0 Likes
Message 3 of 13

guiroehe
Collaborator
Collaborator

Hi, @Felix Möhlmann ,

thank you. I have a few follow-up questions, please:

1. How would you implement this if the object to drag is in a popup menu? I tried it and it does not seem to work;

2. How would the dropscript be written using the object.copy() notation, as createcopy() is deprecated? (this is for my understanding of the difference between the two commands, as they do not seem to produce the same result)

3. What would need to be added to also attach a calculated table to the milestone?

Greatly appreciated!

0 Likes
Message 4 of 13

moehlmann_fe
Enthusiast
Enthusiast

1. I don't know. I asked this as a follow-up under this post.

2. The available parameters differ slightly between object.copy() and createcopy() (use ctrl-f to find the command). But "object.copy(dest)" and "createcopy(object, dest, 1)" should give the same result.

3. Once the query of the Calculated Table is defined it doesn't need any pointer references to other nodes to function, so you could simply copy it into the model like the stats collector.

// Check if calculated table is present in the model
treenode calcTables = Model.find("Tools").subnodes.assert("CalculatedTables");
Object table = calcTables.find("MyCalcTable");
if(!objectexists(table))
{
    // Copy the table into the model
    table = current.subnodes["MyCalcTable"].copy(calcTables);
}

milestone_lib_test_2.fsl

For the table to be shown in the query builder interface, you would need to add a coupling node to the respective table (yellow, under "tables" variable node) and link to that node in any expressions (pink).

1738139434811.png


Message 5 of 13

guiroehe
Collaborator
Collaborator
Hi, @Felix Möhlmann , excellent, thank you very much!

I also realized that the reason my extension was not working is because I created the flexscript nodes in the "folder" mode (colorful node), not "property/variable" mode (grayed node icon) of the host object. My bad!

Thank you very much, Sir!


0 Likes
Message 6 of 13

guiroehe
Collaborator
Collaborator

Hi, @Felix Möhlmann ,

one last silly thing, maybe: I was able to create the table connections between collector and calculated table. However, it seems that the aggregations are lost (at least the column names). I looked into the interface of the CalculatedTable, but I could not find the command used to create the aggregation (or chunk of code). Would you kindle give me a hint about how to do it? Thank you again!


0 Likes
Message 7 of 13

moehlmann_fe
Enthusiast
Enthusiast

Does the link structure match that shown below (coupling node to stats collector under "tables" and the "table" node in the expression tree points to that)? When I recreate that structure in my example library the current value of the "Count When" dropdown is correctly retrieved.

capture.png

capture1.png

milestone-lib-test-3.fsl

Or could you share an example of yours so I can check it?

0 Likes
Message 8 of 13

guiroehe
Collaborator
Collaborator

@Felix Möhlmann ,

yes. But the "column" node gets defaulted to the first column in all aggregations (in your picture "LastMilestoneAchievedColumn"), even if pre-configured in the library object. I want to confirm the proper way of changing the column name via code, as it requires triggering an SQL update, I wonder... That is the information I could not find exploring the tree of the CalculatedTable interface.
Thank you!

0 Likes
Message 9 of 13

moehlmann_fe
Enthusiast
Enthusiast

When opening the Calculated Table GUI and the "column" node is present in the expression's subnodes, then it should check if a column with that same name exists in the linked table and set that as the starting value for the dropdown menu.

I've tested this again with a global table and the pre-configured settings stay after adding the table via the library.

capture.png

It should only default to the first column if the link in the "table" subnode is not properly set. See excerpt from the coldlink code below that populates the menu. (You can access this by right-clicking in the GUI and choosing "View -> Explore Structure". This is a useful function in general to inspect the code behing GUI elements.)

capture1.png

capture2.png

0 Likes
Message 10 of 13

guiroehe
Collaborator
Collaborator
@Felix Möhlmann,

thank you very much!

0 Likes
Message 11 of 13

guiroehe
Collaborator
Collaborator

Hi, @Felix Möhlmann ,

apologies for keep bothering you with this. Would you be able to tell me what I am doing wrong here?

Case A: a dummy object encapsulates the real object, to be able to call a dropscript and install flows, milestone collectors, etc. (as you suggested above).

Result: does not work (object drawing wrong/interrupted, no conveyor system objects - transfer types, etc. - brought in, no object flow brought in)

1738515278914.png

Case B: instead of referring the encapsulated object, the dropscript points to a copy of that object directly on the library root folder.

Result: it works, flow brought in, object successfully drawn. However, the object also appears in the library menu.

1738515655958.png

I could send you the code, but in private, as this is company material. Please let me know and thank you very much once more.

0 Likes
Message 12 of 13

moehlmann_fe
Enthusiast
Enthusiast

Interesting. When I add an object similar to yours (containing conveyors) to a library, the conveyors' visualization node points to the visualization object that gets added to the library alongside the actual object (when using the rightclick menu).

1738653914514.png

When I drag this object into the model or use a dropscript to do so, this reference gets changed to the conveyor system that gets created in the model.

1738653970302.png

For some reason this does not happen when the dropped object is placed inside a dummy object.

When I update the pointer in the dropscript, the conveyors get drawn correctly after dropping the object.

1738654043957.png

test_lib_4.fsl

0 Likes
Message 13 of 13

guiroehe
Collaborator
Collaborator

Hi, @Felix Möhlmann ,

Thank you for your help and attention!

Maybe this is worth reporting as a bug?
I wonder if it could not be related to this another issue I reported: https://answers.flexsim.com/questions/174861/bug-v2502-edit-container-makes-flexsim-to-lose-all.html

Thank you!