Model.group_matches#

Model.group_matches(collection, reference_collection=s_defaultCollection, areaCalcMethod=1, compareType=0, deformationTolerance=0.0, encoding_algorithm=INT_MAX, matchingPercentThreshold=0.0, parentpartsetname='', partsetname='', partsetforunmatched=False, searchMethod='ByEncoding', sphhar_bandwidth=16, sphhar_fallof=2.828427, sphhar_radii=32, resolution=64, unmatchedpartsetname='', hold_license=0, import_encoding_file='', export_encoding_file='', isotropy_tol=DBL_MAX, reuse_ps=0)#

Groups parts into partsets based on matching shapes.

Similar shapes are grouped into to a single partset. A parent partset is created for all different partsets. Unmatched partsets can optionally be put in a new partset. Also see Model.hm_getmatching() to find and group but not create partsets.

Parameters:
  • collection (Collection) – The collection containing the entities.

  • reference_collection (Collection) – The collection containing the entities.

  • areaCalcMethod (int) –

    Specifies how the matching area percentage is calculated when searchMethod=ByArea:

    ByLowestId - Calculate with respect to the entity with the lowest ID (default)

    ByHighestId - Calculate with respect to the entity with the highest ID

  • compareType (int) –

    Specifies with what entities the comparison happens when searchMethod=ByEncoding:

    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 tolerance value to check matching. Valid for searchMethod=ByArea and searchMethod=ByTopo. Default is the global node tolerance.

  • encoding_algorithm (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).

    When searchMethod=ByEncoding, this is reported as (1 - differenceinencoding/deformationTolerance=<value>)

  • parentpartsetname (hwString) – The name for the parent partset. This can have format strings for substituting searchMethod, matchingPercentThreshold and deformationTolerance. Default is “%searchMethod_%matchingPercentThreshold_%deformationTolerance”. When the function is rerun with the same settings, part sets can get overwritten if the same parentpartsetname is provided.

  • partsetname (hwString) – The name for the partset containing matching parts. This can have format strings for introducing representative part names. Default “Matched_%partname” will substitute %partname with the representative (among matches in the group) part name of the group. When the partset is created the name will also have the parent partset ID at the end regardless of the name given here. When the function is rerun with the same settings, part sets can get overwritten if the same partsetname is provided.

  • partsetforunmatched (bool) – If set to 1, creates a separate partset for unmatched parts. Default 0.

  • searchMethod (hwString) –

    The method to perform the comparison:

    ByArea - Use area of entities (default)

    ByEncoding - Use shape encoding

    ByTopo - Use topology comparison

  • sphhar_bandwidth (int) – Optional, valid for encoding_algorithm 0, default 16.

  • sphhar_fallof (double) – Optional, valid for encoding_algorithm 0, default 2.828427.

  • sphhar_radii (int) – Optional, valid for encoding_algorithm 0, default 32.

  • resolution (int) – Optional, valid for encoding_algorithm 0, default 64.

  • unmatchedpartsetname (hwString) – The name for the unmatched partset when partsetforunmatched=1.

  • hold_license (int) – Reserved for future developemnt.

  • import_encoding_file (hwString) – Reserved for future development.

  • export_encoding_file (hwString) – Reserved for future development.

  • isotropy_tol (double) – Reserved for future development.

  • reuse_ps (int) – Reserved for future development.

Examples#

Group all parts by area without any reference#
import hm
import hm.entities as ent

model = hm.Model()

collection = hm.Collection(model, ent.Part)
reference_collection = hm.Collection(model, ent.Part, populate=False)

model.group_matches(
    collection=collection,
    reference_collection=reference_collection
)
Group all parts by area using part with UID “Main” as the reference#
import hm
import hm.entities as ent

model = hm.Model()

collection = hm.Collection(model, ent.Part)
reference_collection = hm.Collection(model, ent.Part, ["Main"])

model.group_matches(
    collection=collection,
    reference_collection=reference_collection
)
Group all parts by shape without any reference, using a custom parent partset name#
import hm
import hm.entities as ent

model = hm.Model()

collection = hm.Collection(model, ent.Part)
reference_collection = hm.Collection(model, ent.Part, populate=False)

model.group_matches(
    collection=collection,
    reference_collection=reference_collection,
    compareType=0,
    parentpartsetname="%searchMethod_%deformationTolerance",
    searchMethod="ByEncoding"
)