Model.replacesetentitydata#

Model.replacesetentitydata(component=Collection(), componentpair=hwCoupleList(), incomingonlyentities=std::vector< EntityFullType >(), preserveCollectSet=CollectionSet())#

Sets the data required for part replacement. This must precede any calls to Model.replacentitywithentity() or Model.replacentitywithentitymark().

The input options may be specified in any order.

Parameters:
  • component (Collection) – The collection containing the component entities to be replaced.

  • componentpair (hwCoupleList) – The list with lists of existing and incoming component ID pairs

  • incomingonlyentities (_EntityFullTypeList_vector) – The list of entity types that are set as ‘accept incoming’.

  • preserveCollectSet (CollectionSet) – The set of collections containing possibly multiple type of entities for ‘accept incoming’ entities to be preserved.

Example#

Replace components with IDs 301 and 302 with IDs 501 and 502 respectively#
import hm
import hm.entities as ent

model = hm.Model()

component_collection = hm.Collection(model, ent.Component, [301, 302])

model.replacesetentitydata(component=component_collection)

preserve_collectionSet = hm.CollectionSet(model)
set_collection = hm.Collection(model, ent.Set, [20, 30])
group_collection = hm.Collection(model, ent.Group, [20, 30])
preserve_collectionSet.set(set_collection)
preserve_collectionSet.set(group_collection)

model.replacesetentitydata(
    preserveCollectSet=preserve_collectionSet,
    componentpair=[[301, 501], [302, 502]],
    incomingonlyentities=[ent.Set, ent.Group],
)

component_collection_for_replace = hm.Collection(model, ent.Component, [501, 502])

model.replacentitywithentitymark(
    mode=1,
    existing_component_collection=component_collection,
    incoming_component_collection=component_collection_for_replace,
    tolerance=0.5,
    keepSrcProp=1,
    keepSrcMat=1,
    keepSrcCompCardimage=1,
)