Model.hm_getmatching#
- Model.hm_getmatching(collection, areaCalcMethod='ByLowestId', compareType=0, deformationTolerance=0.000000, encodingAlgorithm=0, matchingPercentThreshold=0.000000, referenceCollection=Collection(), searchMethod='ByArea', sphharBandwidth=16.000000, sphharFallof=2.828427, sphharRadii=32.000000, sphharResolution=64.000000)#
Performs a comparison and returns matching results.
Returns a matching pair of components or parts passed along with the percentage match. The reference/target entities are sequenced first in the output, followed by matching source entities, and subsequently followed by the matching percentage. If a source entity matches with more than one target, the pairs with maximum match percentage are returned. A source returned with one reference is not part of any other match pair.
- Parameters:
collection (Collection) – The collection containing the entities to compare. Valid entities are components or parts.
areaCalcMethod (hwString) –
Specifies how the matching area percentage is calculated:
ByLowestId - Calculate with respect to the entity with the lowest ID (default).
ByHighestArea - Calculate with respect to the entity with the highest area.
ByLowestArea - Calculate with respect to the entity with the lowest area.
This is ignored when
searchMethod="ByEncoding".compareType (int) –
Specifies with what entities the comparison happens:
0 - Use both CAD and FE from the input selection.
1 - Prefer CAD over FE. This will pick FE only if the input has only FE.
2 - Use only CAD.
3 - Prefer FE over CAD. This will pick CAD only if the input has only CAD.
4 - Use only FE.
deformationTolerance (double) – The matching area threshold above which matching pairs are returned (default is node tolerance).
encodingAlgorithm (int) –
The optional encoding algorithm to use when
searchMethod="ByEncoding". Valid values are:0 - Spherical harmonics (default).
matchingPercentThreshold (double) – The matching area threshold above which matching pairs are returned (default is node tolerance).
referenceCollection (Collection) – The collection containing the reference/target entities. Valid entities are components or parts.
searchMethod (hwString) –
Specifies how the matching is done:
ByArea - Matching is done with repect to area (default).
ByEncoding - Matching is done with respect to encoding.
ByTopo - Matching is done with repect to exact topo matches.
sphharBandwidth (double) – Optional, valid for
encoding_algorithm=0, default 16.sphharFallof (double) – Optional, valid for
encoding_algorithm=0, default 2.828427.sphharRadii (double) – Optional, valid for
encoding_algorithm=0, default 32.sphharResolution (double) – Optional, valid for
encoding_algorithm=0, default 64.
- Returns:
hwReturnStatus- Status objectHmQueryResultList- Result list object containingHmQueryResultobjects with the following output data:
Examples#
Compare part with ID 4 to part with ID 6 use a tolerance of 1.0#import hm import hm.entities as ent model = hm.Model() parts1 = hm.Collection(model, ent.Part, "id=4") parts2 = hm.Collection(model, ent.Part, "id=6") _, resultlist = model.hm_getmatching( collection=parts1, deformationTolerance=1.0, referenceCollection=parts2 ) for result in resultlist: print("referenceEntity: ", result.referenceEntity) print("matchedEntities: ", result.matchedEntities) print("matchPercentage: ", result.matchPercentage)
Compare part with ID 4 to part with ID 6 use the encoding search with a tolerance of 0.6 and use both CAD and FE#import hm import hm.entities as ent model = hm.Model() parts1 = hm.Collection(model, ent.Part, "id=4") parts2 = hm.Collection(model, ent.Part, "id=6") _, resultlist = model.hm_getmatching( collection=parts1, compareType=0, referenceCollection=parts2, searchMethod="ByEncoding" ) for result in resultlist: print("referenceEntity: ", result.referenceEntity) print("matchedEntities: ", result.matchedEntities) print("matchPercentage: ", result.matchPercentage)