BoM Compliance

Query Definition

class BomComplianceQuery

Evaluates compliance for a BoM in the Ansys Granta 1711 XML BoM format against a number of indicators.

All BoM-based queries only operate on a single BoM. As a result, the .with_batch_size() method is not implemented for BoM-based queries.

The methods used to add the BoM and Indicators to this query return the query itself so that they can be chained together as required.

Once the query is fully constructed, use the cxn. run() method to return a result of type PartComplianceQueryResult.

Examples

>>> cxn = Connection("http://localhost/mi_servicelayer").with_autologon().connect()
>>> bom = "<PartsEco xmlns..."
>>> indicator = WatchListIndicator(
...     name="Prop 65",
...     legislation_names=["California Proposition 65 List"]
... )
>>> query = (
...     BomComplianceQuery()
...     .with_bom(bom)
...     .with_indicators([indicator])
... )
>>> cxn.run(query)
<BomComplianceQueryResult: 1 PartWithCompliance results>
with_indicators(indicators)

Add a list or set of WatchListIndicator or RoHSIndicator objects to evaluate compliance against.

Parameters
indicatorslist[WatchListIndicator | RoHSIndicator]
Returns
Query

Current query object.

Raises
TypeError

If the method is called with values that do not match the types described above.

Examples

>>> indicator = WatchListIndicator(
...     name="Prop 65",
...     legislation_names=["California Proposition 65 List"]
... )
>>> MaterialComplianceQuery().with_indicators([indicator])
<MaterialCompliance: 0 materials, batch size = 100, 1 indicators>
with_bom(bom)

Set the BoM to use for the query.

The BoM must be in the Ansys Granta 1711 XML BoM format.

Parameters
bomstr

BoM to use for the query.

Returns
Query

Current query object.

Raises
TypeError

If the method is called with values that do not match the types described above.

Notes

The XML schema is defined by the schema document BillOfMaterialsEco.xsd, which in turn references grantarecord1205.xsd. Together, these XSD files can be used to validate that the BoM is both valid XML and adheres to the Ansys Granta 1711 XML BoM schema.

Examples

>>> my_bom = "<PartsEco xmlns..."
>>> query = BomComplianceQuery().with_bom(my_bom)

Query Result

class BomComplianceQueryResult(results, indicator_definitions, messages)

Retrieves the result of running the BomComplianceQuery class. This class summarizes the compliance status of a BoM against one or more indicators.

Notes

Objects of this class are only returned as the result of a query. The class is not intended to be instantiated directly.

compliance_by_indicator

Compliance status for each indicator in the original query. The indicator name is used as the dictionary key.

The result for each indicator is determined by taking the worst result for that indicator across all items included in the query.

Returns
dict[str, WatchListIndicator | RoHSIndicator]

Examples

>>> compliance_result: MaterialComplianceQueryResult
>>> compliance_result.compliance_by_indicator
{'Prop 65': <WatchListIndicator,
        name: Prop 65,
        flag: WatchListFlag.WatchListAboveThreshold>
}
compliance_by_part_and_indicator

Compliance status for each root part included in the BoM specified in the original query.

Returns
list[PartWithComplianceResult]

Examples

>>> result: BomComplianceQueryResult
>>> result.compliance_by_part_and_indicator
[<PartWithComplianceResult, 1 indicators>]
messages

Messages generated by Granta MI when running the query. The presence of one or more messages means that something unexpected happened when running the query but that the query could still be completed.

Messages are sorted in order of decreasing severity and are available in the Service Layer log file.

Messages are also logged using the Python logging module to the ansys.grantami.bomanalytics logger. By default, messages with a severity of warning or higher are printed on stderr.

Returns
list[LogMessage]

Examples

>>> result: MaterialImpactedSubstancesQueryResult
>>> result.messages
[LogMessage(severity='warning', message='Material "ABS+PVC (flame retarded)" has
    2 substance row(s) with missing substance links.')]