question

Jane T avatar image
0 Likes"
Jane T asked Ryan Clark commented

Is there a way to create new zone subsets using flexscript?

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.

flexscriptflexsim 21.1.0zonezone subset
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Hi @jane.t, was Felix Möhlmann's answer helpful? If so, please click the red "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered

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.

1629705419040.png

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.


1629705419040.png (18.4 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.