question

Gensho H avatar image
0 Likes"
Gensho H asked Gensho H commented

How to count the number of objects/activities in a simulation model?

I'd like to count the number of objects and activities which are used in a simulation model.

FlexSim 18.0.10
number of objectscount the number
5 |100000

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

1 Answer

·
asb.p avatar image
0 Likes"
asb.p answered Gensho H commented

All the objects in the simulation model will be under the model tree.

To count the number of objects in a simulation model, You can simply use

int numObjs = model().subnodes.length;

you will get the total number of objects in the model in numObjs variable which includes 1 node for model floor and 1 node for Tools

If you also want to know the total number of global tables, user commands etc then you need to go in to tools node to count.

int totalTables=model().find("Tools/GlobalTables").subnodes.length

you can similarly reference the other tools and count respective totals


modeltree.png (5.6 KiB)
· 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.

Gensho H avatar image Gensho H commented ·

Thank you asb.

I tried to use this script like the image, but it did't return the correct value.

Could you please check if it's correct.

0 Likes 0 ·
img.jpg (7.4 KiB)
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Gensho H commented ·

@Gensho H

Either put just

model().subnodes.length

or return numObjs

int numObjs = model().subnodes.length;
return numObjs;
0 Likes 0 ·
Gensho H avatar image Gensho H Matthew Gillespie ♦♦ commented ·

Thank you all. It works.

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.