Is there a way to add subsets to a zone using flexscript? Instead of manually adding subsets using the UI I would like to do it using code if possible.
Creating a new subset from scratch seems quite difficult. You might have to look at the module SDK for that.
Creating copies of an existing subset and modifying it is relatively easy however, as you can copy the relevant subnodes in the tree.
// Navigate to the subset treenode treenode Subsets = Model.find("/Tools/ProcessFlow/ProcessFlow/Zone>variables/subsets"); // Create a copy of the first subnode (subset) as a new subnode treenode NewSubset = createcopy(Subsets.first, Subsets, 0); // Edit the value for the criteria in the copy setsdtvalue(NewSubset, "subsetCriteria", "Type = 3");
This code will create a copy of the first defined subset for the zone and set its token selection criteria to "Type = 3". For other options have a look at the structure and contents of the zones tree.
Doing this while the model is running might have varying results. While I didn't get an error message when I tested it. The statistics for the zone broke though. But entering tokens got added to the new subset correctly.
17 People are following this question.