Model.replacenodes#

Model.replacenodes(source_node=Entity(), target_node=Entity(), source_list=s_defaultEntityList, target_list=s_defaultEntityList, equiv=1, midpoint=0, collapse_check=1)#

Replaces single or multiple nodes simultaneously with a single function.

Parameters:
  • source_node (Entity) – The object describing the source node entity to be replaced.

  • target_node (Entity) – The object describing the target node entity to be replaced with.

  • source_list (EntityList) – The list of source node entities to be replaced.

  • target_list (EntityList) – The list of target node entities to be replaced with.

  • equiv (int) –

    The equivalence option. Valid values are:

    0 - All nodes are retained.

    1 - Nodes are equivalenced (default).

  • midpoint (int) –

    The location option. Valid values are:

    0 - Source Nodes are moved to target nodes (default).

    1 - Source nodes and target nodes are replaced to midpoint.

  • collapse_check (int) –

    The option to check element collapsing. Valid values are:

    1 - Warn if element collapses on node replace (default).

    2 - Do not warn but always replace irrespectively.

    3 - Do not warn but do not replace nodes when element collapse happens.

Example#

Replace the source nodes with IDs 1, 2 and 3 to target nodes with IDs 4, 5 and 6 with only target nodes remain and replace nodes without warn#
import hm
import hm.entities as ent

model = hm.Model()

model.replacenodes(
    source_list=[ent.Node(model, 1), ent.Node(model, 2), ent.Node(model, 3)],
    target_list=[ent.Node(model, 4), ent.Node(model, 5), ent.Node(model, 6)],
    equiv=1,
    midpoint=0,
    collapse_check=2,
)