{ "cells": [ { "cell_type": "markdown", "id": "7f3f7ba6", "metadata": {}, "source": [ "# Perform a BoM sustainability summary query\n", "\n", "The following supporting files are required for this example:\n", "\n", "* [bom-2301-assembly.xml](supporting-files/bom-2301-assembly.xml)" ] }, { "cell_type": "markdown", "id": "408dda36", "metadata": {}, "source": [ "## Run a BoM sustainability summary query\n", "\n", "First, connect to Granta MI.\n" ] }, { "cell_type": "code", "execution_count": null, "id": "8666ccc7", "metadata": {}, "outputs": [], "source": [ "from ansys.grantami.bomanalytics import Connection" ] }, { "cell_type": "code", "execution_count": null, "id": "37f89ddb", "metadata": {}, "outputs": [], "source": [ "server_url = \"http://my_grantami_server/mi_servicelayer\"\n", "cxn = Connection(server_url).with_credentials(\"user_name\", \"password\").connect()" ] }, { "cell_type": "markdown", "id": "67f951c5", "metadata": {}, "source": [ "Next, create a sustainability summary query. The query accepts a single BoM as argument and an optional\n", "configuration for units. If a unit is not specified, the default unit is used. Default units for the analysis are\n", "``MJ`` for energy, ``kg`` for mass, and ``km`` for distance." ] }, { "cell_type": "code", "execution_count": null, "id": "dc79c5a6", "metadata": {}, "outputs": [], "source": [ "xml_file_path = \"supporting-files/bom-2301-assembly.xml\"\n", "with open(xml_file_path) as f:\n", " bom = f.read()\n", "\n", "from ansys.grantami.bomanalytics import queries\n", "\n", "MASS_UNIT = \"kg\"\n", "ENERGY_UNIT = \"MJ\"\n", "DISTANCE_UNIT = \"km\"\n", "\n", "sustainability_summary_query = (\n", " queries.BomSustainabilitySummaryQuery()\n", " .with_bom(bom)\n", " .with_units(mass=MASS_UNIT, energy=ENERGY_UNIT, distance=DISTANCE_UNIT)\n", ")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }