Model.hm_count#

Model.hm_count(entity_name, selection_flag, config_num=0, type_num=0)#

Counts the entities in the database.

Parameters:
  • entity_name (hwString) – The name of entity to be counted. This parameter may be set to any of the entities in the database.

  • selection_flag (hwString) – Indicates which entities are to be counted. Valid values are all and displayed.

  • config_num (int) – The configuration number of the entities to be counted. This parameter is used only if <entity type> is set to elements or loads. If set to zero, the entities are counted regardless of their configuration.

  • type_num (int) – The type number of the entities to be counted. This parameter is used only if entity_name="elements". If set to zero, all of the entities are counted regardless of their type.

Returns:

Example#

Count all the component entities that exist in the database#
import hm
import hm.entities as ent

model = hm.Model()

_,result=model.hm_count(
    entity_name="Component",
    selection_flag="all"
)

print("Count: ", result.count)

Note

In the template function @count(), if the displayed option is selected (active) on the export data panel, the value returned by @count() includes only those entities that are currently displayed. In the Tcl/Tk function hm_count(), this has to be indicated explicitly using the argument selection_flag.