Adding custom objects in respective group?

Adding custom objects in respective group?

rajankur6494
Advocate Advocate
218 Views
8 Replies
Message 1 of 9

Adding custom objects in respective group?

rajankur6494
Advocate
Advocate

[ FlexSim 21.1.5 ]

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


0 Likes
Accepted solutions (1)
219 Views
8 Replies
Replies (8)
Message 2 of 9

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

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

0 Likes
Message 3 of 9

rajankur6494
Advocate
Advocate
Hi @Jason Lightfoot,

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

Thank you!

0 Likes
Message 4 of 9

Jeanette_Fullmer
Community Manager
Community Manager
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
Message 5 of 9

Jeanette_Fullmer
Community Manager
Community Manager

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.find(">superclasses").subnodes[1].name == "FixedResource" && Group("Group1").indexOf(tree.as(Object)) == 0){
Group("Group1").addMember(tree);
} 
}

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
Message 6 of 9

rajankur6494
Advocate
Advocate

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
Message 7 of 9

Jeanette_Fullmer
Community Manager
Community Manager

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.find(">classes").subnodes[1].name == "People::Staff" && Group("Staff").indexOf(tree.as(Object)) == 0){
      Group("Staff").addMember(tree);
   } 
}

Model Link

0 Likes
Message 8 of 9

Jeanette_Fullmer
Community Manager
Community Manager

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
Message 9 of 9

jason_lightfootVL7B4
Autodesk
Autodesk

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