Model.hm_getentitycreationid#
- Model.hm_getentitycreationid(entity_type, pool_id, entity)#
Returns a valid entity ID that can be used to renumber both the creating and mapping entities. If the function returns 0, it means the new entity can use any ID. If the function returns a valid ID, both the new entity and mapped entity need to be renumbered to use the returned ID.
- Parameters:
entity_type (EntityFullType) – The entity type for the creating entity.
pool_id (int) – The solver ID pool number for the creating entity. A value of 0 indicates no solver ID pool.
entity (Entity) – The object describing the mapping entity. If
Noneis passed, the function should find an ID for renumbering both the creating and mapping entities.
- Returns:
hwReturnStatus- Status objectHmQueryResult- Result object containing the output values:newEntityId (int)
Example#
Create a new component named “ myComp “ whose ID should map with its assigned property ID of 100#import hm import hm.entities as ent model = hm.Model() _, result = model.hm_getentitycreationid( entity_type=ent.Component, pool_id=0, entity=ent.Property(model, 100) ) newID = result.newEntityId myComp = ent.Component(model, name="myComp", color=5) compID = myComp.id if newID != 0: if newID != 100: # Renumber the property model.renumbersolverid( collection=hm.Collection(model, ent.Property, [100]), start_id=newID, incr_val=1, offset_val=0, offset_flag=0, reserved_1=0, reserved_2=0, reserved_3=0, ) if newID != compID: # Renumber the component model.renumbersolverid( collection=hm.Collection(model, ent.Component, "name=myComp"), start_id=newID, incr_val=1, offset_val=0, offset_flag=0, reserved_1=0, reserved_2=0, reserved_3=0, )