question

Ankur A3 avatar image
0 Likes"
Ankur A3 asked Jason Lightfoot edited

Adding custom objects in respective group?

Hi Team,

Once objects are dropped from custom library instead of standard library, it is not available in respective group. I need to add it manually in group every time to make model work.1663008048410.png


Is there any better way to do it?

Thank you!

@Sebastián Cañas


FlexSim 21.1.5
groupobjectsdefaultcustom library
1663008048410.png (97.9 KiB)
· 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.

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @Ankur A3, was our answer 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 ·

1 Answer

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

Add them as group members on reset (or use the OnDrop or OnCreate triggers for when you drag the object into the model)

· 6
5 |100000

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

Ankur A3 avatar image Ankur A3 commented ·
Hi @Jason Lightfoot,

Can you explain little more since I have no idea about it?

Thank you!

0 Likes 0 ·
Jeanette F avatar image Jeanette F ♦♦ Ankur A3 commented ·
Hello @Ankur A3, I am trying to make a sample model to show you but if you could share your model that would be helpful. Please reference the top of the page for how to share a model since the upload feature is not working at the moment.
0 Likes 0 ·
Jeanette F avatar image Jeanette F ♦♦ Ankur A3 commented ·

Hello @Ankur A3,

I have an on reset trigger that adds objects to a group if the object fit a certain super class and that are not already in a group.

Array tree= model.subnodes.toArray();
for (int i=2; i<= tree.length; i++){
if(tree[i].find(">superclasses").subnodes[1].name == "FixedResource" && Group("Group1").indexOf(tree[i].as(Object)) == 0){
Group("Group1").addMember(tree[i]);
} 
}

If you were to open the Model Tree you will see that all objects are listed in the tree and I just go through that list of objects.

1663125405252.pngIf you were to investigate on of those nodes you would notice that there is a subnode called superclasses that I am using to identify what items should be added. You will need to look at your custom objects and see if there is a unique class or superclass that will help you identify them and add them to the group.

1663125453548.png

Model Link

0 Likes 0 ·
1663125405252.png (5.9 KiB)
1663125453548.png (7.4 KiB)
Ankur A3 avatar image Ankur A3 commented ·

Hi @Jeanette F,

Thank you for your answer.

I wanted to add custom library objects (like standard library objects) in default groups so that it can be used in process flow.

Here is the screenshot:

1663261809882.png

I have uploaded model in cloud with name "Default_Gp_Custom_Library". How can I get link to paste here directly?

Thank you!

0 Likes 0 ·
Jeanette F avatar image Jeanette F ♦♦ Ankur A3 commented ·

Hello @Ankur A3, You can look into the objects tree and go to classes. This is where I found the distinguishable information to put something in the Staff, Location, ect. group.

1663359595551.png

You can use the following code in the script window or on reset trigger for Staff. You can easily change it for location or equipment.

Array tree= model.subnodes.toArray();
for (int i=2; i<= tree.length; i++){
   if(tree[i].find(">classes").subnodes[1].name == "People::Staff" && Group("Staff").indexOf(tree[i].as(Object)) == 0){
      Group("Staff").addMember(tree[i]);
   } 
}

Model Link

0 Likes 0 ·
1663359595551.png (10.1 KiB)
Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·

In the reset trigger of the object put something like:

Group("MyGroup").addMember(current);

This doesn't fire for library objects but will fire after you've dragged them into the model and press reset. Duplicates are handled by default so you don't get more than one entry for each object.

0 Likes 0 ·

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.