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.

Jacob W2 avatar image Jacob W2 ♦ commented ·

Hi @Ankur A3, was one of Arun Kr's or Jason Lightfoot's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. 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 ·
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:

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

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

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

For 17 and 17.1 use

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
1 Like"
Arun Kr answered Arun Kr edited

Hi ,

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

Furthermore, to add members to the group use

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.

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.