question

Chidambaram avatar image
0 Likes"
Chidambaram asked Logan Gold commented

Rearrange objects or Rename objects within group

Hi I like to know is there a simple way to rearrange or rename object within group?

For instance Group 1 has 5 objects (Queue 1 to 5) that are attached to a plane. When i copy and paste the plane , the objects are adding to the same group ( but not in chronological order like Queue1,queue2,.. ). The order is collapsed (refer plane 3 objects). Refer attached model for reference.


(1) Either i like to rearrange objects within the same group or

(2) I like to duplicate the parent group ( Group1 ) and duplicate the group named (Group1) to Group 2 and then rename the objects within the group . For instance : Group 1 will have > Plane1/Queue1 , in Group 2 should have > Plane2/Queue1 . I need to change the object name instead of Plane1 to plane2 with scripts. Rearrange within group.fsm


1736987175030.png

FlexSim 24.2.2
groupobjectsrearrange
· 3
5 |100000

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

Chidambaram avatar image Chidambaram commented ·

@Jason Lightfoot Could you please help me on this ?

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Chidambaram commented ·
Hi - I'd like a bit of context to understand what you're trying to do and why you're using Groups.

When I'm using containers and need references to the objects within them I'm mostly creating label arrays of pointers and avoiding groups entirely. In your example that would be a label called 'queues' on the container/template that has 5 entries in the correct sequence - each being a pointer to a queue. That array can then be used as if it were a group within an object process flow activity just by referring to current.queues rather than Group("Group1").


1 Like 1 ·
Logan Gold avatar image Logan Gold ♦♦ commented ·

Hi @Chidambaram, was Felix Möhlmann's answer helpful? If so, please click the "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 comment back to reopen your question.

0 Likes 0 ·

1 Answer

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

1) You could just run a sorting algorithm over the group members, sorting them by their tree rank (and that of their parent node).

// Bubblesort
treenode group = Group("Group1");
Object obj1; Object obj2; for(int i = 2; i <= group.subnodes.length; i++) {     for(int j = group.subnodes.length; j > i; j--)     {         obj1 = ownerobject(group.subnodes[j].value);         obj2 = ownerobject(group.subnodes[j-1].value);         if(obj1.rank + obj1.up.rank*100 < obj2.rank + obj2.up.rank*100)         {             group.subnodes[j].rank = j-1;         }     } }

2) Creating a copy of the plane and adding its subnodes to a new group is also possible.

Object basePlane = Model.find("Plane1");
int index = 2; Group newGroup = Tools.create("Group"); newGroup.name = "Group" + index; Object newPlane = createcopy(basePlane, basePlane.up); newPlane.name = "Plane" + index; for(int i = 1; i <= newPlane.subnodes.length; i++) {     newGroup.addMember(newPlane.subnodes[i]); }
5 |100000

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