In 16.1 we added some new group commands, two of which are very helpful in this situation:
groupnummembers(groupName) - returns the number of group members
groupmember(groupName, rank) - returns the group member at the specified rank
Using these new commands we can write the following code to loop through the group members:
for(int i = 1; i <= groupnummembers("Group1"); i++) { pt(getname(groupmember("Group1", i))); pr(); }
Kim Jh,
Here is an alternative approach if you are using an earlier version than 16.1:
All groups are located in the node "Tools/Groups" in the model. The following code will print the names of all the objects in "Group1" to the output console.
treenode groups = node("/Tools/Groups", model()); treenode mygroup = node("/Group1", groups); for(int i1 = 1; i1 <= content(mygroup); i1++){ treenode tempobj = ownerobject(tonode(getnodenum(rank(mygroup, i1)))); pr(); pt(getname(tempobj)); }
The nodes in the group are couplings to the objects in the group. The code that sets the tempobj variable is the method that I use to get the node that owns the other side of that coupling.
Good Luck,
Brandon
5 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved