Model.CE_UpdateLink#
- Model.CE_UpdateLink(id, search_entity, search_name, search_rule, replace_entity, replace_name, replace_rule, replace_state, keep_current_state=0, search_uid=s_defaultString, replace_uid=s_defaultString)#
Allows search and replace of an existing link in the specified connector with a new link entity.
- Parameters:
id (unsigned int) – The connector ID to update.
search_entity (Entity) – The object describing the entity to search in the connector. This must be specified. The supported entities are Component, Property, Surface, Tag, Element, Node and Part.
search_name (hwString) –
The name of the link entity to replace in the connector. The name is optional only if one of the following is true:
1 - None
2 - Use ID
4 - Proximity
5 - Use UID
search_rule (unsigned int) –
The rule by which the link entity was added to the connector. The following codes define the different rules:
0 - Undefined
1 - None
2 - Use ID
3 - Use name
4 - Proximity
5 - Use UID
If the rule is specified, the entity search is performed in accordance with the rule.
For example, a search_rule of 2 requires
search_entity.replace_entity (Entity) – The object describing the entity that replaces the found link entity (
search_entity) in the connector. If not specified, the entity type information is not replaced for the found link (replace_type =search_entity). The supported types are the same as that forsearch_entity.replace_name (hwString) – The entity Name that replaces the found link entity. If not specified, the entity name information is not replaced for the found link (replace_name =
search_name).replace_rule (unsigned int) – The rule to set for the found link entity. All the rules supported for
search_ruleparameters are supported.replace_state (unsigned int) –
The flag to set for the link entity that specifies if you are connecting to mesh or togeometry. The supported values are:
0 - Undefined
1 - Connect to mesh
2 - Connect to geometry
keep_current_state (unsigned int) –
Optional option to keep the current connector state after the update operation. Valid states are:
0 - Unrealize if needed (default)
1 - Keep current state
At most, one of the “replace” data must be specified to see a change in the link attributes. If the replace data exactly matches the search data, the connector is not unrealized and no change is made to the link entity.
search_uid (hwString) – The UID of the link entity to replace in the connector. The UID is optional, only if
search_ruleis 1, 2, 3 or 4.replace_uid (hwString) – The entity UID that replaces the found link entity. If not specified, the entity UID information is not replaced for the found link (replace_uid =
search_uid).
Examples#
Replace component with ID 10 with component with ID 20 for connector with ID 1#import hm import hm.entities as ent model = hm.Model() model.CE_UpdateLink( id=1, search_entity=ent.Component(model, 10), search_name="", search_rule=0, replace_entity=ent.Component(model, 20), replace_name="", replace_rule=0, replace_state=0 )
Replace component with name “comp1” with component with name “bumper” for connector with ID 1#import hm import hm.entities as ent model = hm.Model() model.CE_UpdateLink( id=1, search_entity=None, search_name="comp1", search_rule=0, replace_entity=None, replace_name="bumper", replace_rule=0, replace_state=0 )
Replace use-id with use-name rule for component with ID 10 for connector with ID 1#import hm import hm.entities as ent model = hm.Model() model.CE_UpdateLink( id=1, search_entity=ent.Component(model, 10), search_name="", search_rule=2, replace_entity=ent.Component(model, 20), replace_name="", replace_rule=3, replace_state=0 )
Replace the state for component with ID 10 in connector with ID 1 from “connect to elems” to “connect to geom”#import hm import hm.entities as ent model = hm.Model() model.CE_UpdateLink( id=1, search_entity=ent.Component(model, 10), search_name="", search_rule=0, replace_entity=None, replace_name="", replace_rule=0, replace_state=2 )
Note
In all the above cases, the connector entity is unrealized and any existing welds are removed from the connector. At most, one of the “replace” data must be specified to see a change in the link attributes. If the replace data exactly match the search data, the connector is not unrealized and no change is made to the link entity.