Model.replacentitywithentity#
- Model.replacentitywithentity(mode, entity_type, existing_id, incoming_id, tolerance=0.01, keep_src_prop=0, keep_src_mat=0, keep_src_comp_cardimage=0, keep_src_include=0, log_file='')#
Replaces a single component.
- Parameters:
mode (int) –
The replace mode. Valid values are:
0 - Undo/reject replace operation.
1 - Initial replace operation.
2 - Finish/accept replace operation.
entity_type (EntityFullType) – The type of entity to replace. Currently only supported for components.
existing_id (int) – The ID of the existing/old entity.
incoming_id (int) – The ID of the incoming/new entity.
tolerance (double) – The replacement tolerance. Right now it is a global tolerance, meaning the same tolerance is applied for all replace entities. The default is 0.01.
keep_src_prop (int) –
0 - Do not reuse/keep the property assigned to the outgoing component (default).
1 - Reuse/ assign property of source component to the outgoing component.
keep_src_mat (int) –
0 - Do not reuse/keep the material assigned to the outgoing component (default).
1 - Reuse/assign material of source component to the outgoing component.
keep_src_comp_cardimage (int) –
0 - Do not reuse/keep the card image assigned to the outgoing component (default).
1 - Reuse/ assign source component card image to the outgoing component.
keep_src_include (int) –
0 - Do not organize the incoming component to the outgoing component include (default) .
1 - Organize the incoming component and its nodes/elements/reference entities to the outgoing component include.
log_file (hwString) – If a log file is desired, value should be set to the full path and file name to write to.
Example#
Replace the component with ID 301 with component with ID 501 use a tolerance of 0.5, keep the source material, property and card image#import hm import hm.entities as ent model = hm.Model() component_collection = hm.Collection(model, ent.Component, [100]) model.replacesetentitydata(component=component_collection, componentpair=[[301, 501]]) model.replacentitywithentity( mode=1, entity_type=ent.Component, existing_id=301, incoming_id=501, tolerance=0.5, keep_src_prop=1, keep_src_mat=1, keep_src_comp_cardimage=1, )