question

Ankur A3 avatar image
1 Like"
Ankur A3 asked Jacob W2 commented

Creating Group Using Flexscript?

Hi Team,

I am trying to create group using flexscript with custom name. I am using follwing code:

Group newGroup = createinstance(Group, treenode);

It is not working. I feel this syntax is not correct.

Can you help me how to proceed?

Thank you!

FlexSim 21.1.5
flexscriptcreate group
· 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.

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

For versions 22.1 and earlier (the OP's version is 21) use:

  1. string newgroupname="MyNewGroup";
  2. treenode groups=Model.find("Tools").subnodes.assert("Groups");
  3. treenode group=groups.subnodes[newgroupname];
  4. if (!group) {
  5.     treenode group=createinstance(maintree().find("project/library/Group"),groups);
  6.     group.name=newgroupname;
  7. }

to add members in 17.2 and later versions use the same as Arun's answer:

  1. Group("MyNewGroup").addMember(<objectref>);

For 17 and 17.1 use

  1. groupaddmember(<groupname>,<objectref>)
5 |100000

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

Arun Kr avatar image
0 Likes"
Arun Kr answered Arun Kr edited

Hi ,

  1. Group group = Tools.create("Group"); // Create group using the new Tools API
  2. group.name = "xyz"; // Custom name to the group

Furthermore, to add members to the group use

  1. group.addMember();

Regards,

Arun KR

5 |100000

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