Model.hm_latestentityid#

Model.hm_latestentityid(entity_type, num=0)#

Returns the ID of the last created entity. An option is also available to return the ID of previously created entities (up to 99).

Parameters:
  • entity_type (EntityFullType) – The type of entity to return the last created ID for.

  • num (int) – Queries a specific entity created previously before the last entity. The maximum is 99. Default is 0 (last entity).

Returns:

Examples#

Get the latest created component#
import hm
import hm.entities as ent

model = hm.Model()

_,result = model.hm_latestentityid(entity_type=ent.Component)

print("entity", result.entity)
Get the previous latest and first previous node created on line with ID 100#
import hm
import hm.entities as ent

model = hm.Model()

lines = hm.Collection(model, ent.Line, [100])

# Create two nodes on the line
model.nodecreateonlines(
    collection=lines,
    number=2,
    bias_style=0,
    bias_intensity=0.0,
)

# Get the last created node
_, result = model.hm_latestentityid(entity_type=ent.Node, num=0)

print("entity", result.entity)

# Get the first previously created node
_, result = model.hm_latestentityid(entity_type=ent.Node, num=1)

print("entity", result.entity)