BoM Impacted Substances Query

Query Definition

class BomImpactedSubstancesQuery

Gets the substances impacted by a list of legislations for a BoM in the Ansys Granta 1711 XML BoM format.

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.

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

Examples

>>> cxn = Connection("http://localhost/mi_servicelayer").with_autologon().connect()
>>> bom = "<PartsEco xmlns..."
>>> query = (
...     BomImpactedSubstancesQuery()
...     .with_bom("<PartsEco xmlns...")
...     .with_legislations(["REACH - The Candidate List"])
... )
>>> cxn.run(query)
<BomImpactedSubstancesQueryResult: 1 Bom1711WithImpactedSubstances results>
with_legislations(legislation_names)

Add a list or set of legislations to retrieve the impacted substances for. The legislation records are referenced by legislation name.

Parameters
legislation_nameslist[str] | set[str]
Returns
Query

Current query object.

Raises
TypeError

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

Examples

>>> query = MaterialImpactedSubstancesQuery()
>>> query = query.with_legislations(["California Proposition 65 List",
>>>                                  "REACH - The Candidate List"])
<MaterialImpactedSubstances: 0 materials, batch size = 100, 2 legislations>
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 BomImpactedSubstancesQueryResult(results, messages)

Retrieves the result of running the BomImpactedSubstancesQuery class. This class describes the substances in the specified BoM impacted by one or more legislations.

Notes

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

impacted_substances_by_legislation

View of the results for a query for impacted substances, grouped by legislation only.

The substances from all items specified in the query are merged for each legislation, providing a single list of impacted substances grouped by legislation only. Substances are duplicated where they appear in multiple items for the same legislation.

Returns
impacted_substancesdict[str, ImpactedSubstance]

Examples

>>> result: MaterialImpactedSubstancesQueryResult
>>> result.impacted_substances_by_legislation
{'REACH - The Candidate List': [
    <ImpactedSubstance: {"cas_number": 90481-04-2}>, ...]
}
impacted_substances

View of the results for a query for impacted substances, flattened into a single list.

The substances from all items specified in the query are merged across item and legislation, providing a single flat list. Substances are duplicated where they appear in multiple items or legislations.

Returns
impacted_substanceslist[ImpactedSubstance]

Examples

>>> result: MaterialImpactedSubstancesQueryResult
>>> result.impacted_substances
[<ImpactedSubstance: {"cas_number": 90481-04-2}>, ...]
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.')]

BoM Result

The BoMWithImpactedSubstancesResult object does exist, but it is not documented because it is not exposed by any public methods. The rationale is as follows:

A single Query Definition query can only operate on a single BoM. Therefore, there is no grouping of impacted substances by BoM, which is what the BoMWithImpactedSubstancesResult would be used for. Impacted Substances objects are only available either as a flat list or grouped by legislation. Both of these views are available on the Query Result object above.