diff --git a/LeoCAD/Scooter.ldr b/LeoCAD/Scooter.ldr new file mode 100644 index 0000000000000000000000000000000000000000..220624964b3f991b14c008739748a97713fe0efb --- /dev/null +++ b/LeoCAD/Scooter.ldr @@ -0,0 +1,25 @@ +0 +0 Name: New Model.ldr +0 Author: +1 71 180 -48 0 1 0 0 0 1 0 0 0 1 56904.dat +1 0 180 -48 0 1 0 0 0 1 0 0 0 1 30699.dat +1 4 260 -57.8657 -50 1 0 0 0 1 0 0 0 1 2730.dat +1 71 180 -48 -30 0 0 1 0 1 0 -1 0 0 32073.dat +1 47 180 -48 -30 1 0 0 0 1 0 0 0 1 3713.dat +1 47 180 -48 -70 1 0 0 0 1 0 0 0 1 3713.dat +1 71 340 -48 0 1 0 0 0 1 0 0 0 1 56904.dat +1 0 340 -48 0 1 0 0 0 1 0 0 0 1 30699.dat +1 71 340 -48 -30 0 0 1 0 1 0 -1 0 0 32073.dat +1 47 340 -48 -30 1 0 0 0 1 0 0 0 1 3713.dat +1 47 340 -48 -70 1 0 0 0 1 0 0 0 1 3713.dat +1 47 220 -128 -70 1 0 0 0 0 1 0 -1 0 40490.dat +1 47 220 -208 -70 0 0 1 0 1 0 -1 0 0 32073.dat +1 47 220 -208 -25 -1 0 0 0 1 0 0 0 -1 32123.dat +1 47 220 -208 -35 -1 0 0 0 1 0 0 0 -1 32123.dat +1 47 220 -208 -45 -1 0 0 0 1 0 0 0 -1 32123.dat +1 47 220 -208 -55 -1 0 0 0 1 0 0 0 -1 32123.dat +1 47 220 -208 -85 -1 0 0 0 1 0 0 0 -1 32123.dat +1 47 220 -208 -95 -1 0 0 0 1 0 0 0 -1 32123.dat +1 47 220 -208 -105 -1 0 0 0 1 0 0 0 -1 32123.dat +1 47 220 -208 -115 -1 0 0 0 1 0 0 0 -1 32123.dat +1 47 220 -48 -60 0 0 1 0 -1 0 1 0 0 3673.dat diff --git a/figures/leocad_screenshot_cut.png b/figures/leocad_screenshot_cut.png index a0e18f79fcf6f27a5915f8b3759958f0e3a2dd96..e598de3be69f3e15f94641d3e2918b2df31d9d37 100644 Binary files a/figures/leocad_screenshot_cut.png and b/figures/leocad_screenshot_cut.png differ diff --git a/functions/classes.py b/functions/classes.py index 49f6eed52dd6177b4cbb6a08acbcf5b99e027193..5e0e8a38cfa13a21d26d358f8198dee6fa4cd2e5 100644 --- a/functions/classes.py +++ b/functions/classes.py @@ -57,7 +57,7 @@ class LegoComponent: to None. datasheet (dict[str, Any], optional): Metadata describing the component, read from datasheet. Defaults to None. - more_properties tuple of dict, dict + more_properties (dict[str, Any]) Additional dictionaries representing custom properties. kwargs Arbitrary keyword arguments representing custom properties. diff --git a/minimalbeispiel.ipynb b/minimalbeispiel.ipynb index b1121cb5ec9bbfa59114c1b0a6c3d511dd09d365..b90e06191b64ba2c8054cec8fd3b12d17916ca2a 100644 --- a/minimalbeispiel.ipynb +++ b/minimalbeispiel.ipynb @@ -46,15 +46,8 @@ "metadata": {}, "source": [ "#### Versuchsaufbau:\n", - "Die folgende Abbildung zeigt den Versuchsaufbau des Minimalbeispiels in LeoCAD. Die transparenten Bauteile sind dabei nicht Teil des hier erläuterten Zusammenbaus, können aber mit dem zur Verfügung gestellten Baukasten ergänzt werden:" - ] - }, - { - "cell_type": "markdown", - "id": "2f969ed9", - "metadata": {}, - "source": [ - "" + "Die folgende Abbildung zeigt den Versuchsaufbau des Minimalbeispiels in LeoCAD. Die transparenten Bauteile sind dabei nicht Teil des hier erläuterten Zusammenbaus, können aber mit dem zur Verfügung gestellten Baukasten ergänzt werden:\n", + "" ] }, { @@ -105,13 +98,14 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'item number': 32073, 'item description': 'Axle 5 studs', 'category': 'axle', 'price [Euro]': 0.001, 'mass [g]': 0.66, 'delivery time [days]': 3, 'data source': 'https://www.bricklink.com/v2/catalog/catalogitem.page?P=32073#T=S&O={%22iconly%22:0}', 'dimension [studs]': 5}\n", + "{'item number': 32073, 'item description': 'Axle 5 studs', 'category': 'axle', 'price [Euro]': 0.001, 'mass [g]': 0.66, 'environmental impact [kg CO2e /kg]': 11.03, 'delivery time [days]': 3, 'data source': 'https://www.bricklink.com/v2/catalog/catalogitem.page?P=32073', 'dimension [studs]': 5}\n", "front axle\n", "{'category': 'axle',\n", " 'color': 'grey',\n", - " 'data source': 'https://www.bricklink.com/v2/catalog/catalogitem.page?P=32073#T=S&O={%22iconly%22:0}',\n", + " 'data source': 'https://www.bricklink.com/v2/catalog/catalogitem.page?P=32073',\n", " 'delivery time [days]': 3,\n", " 'dimension [studs]': 5,\n", + " 'environmental impact [kg CO2e /kg]': 11.03,\n", " 'item description': 'Axle 5 studs',\n", " 'item number': 32073,\n", " 'label': 'back axle',\n", @@ -134,7 +128,7 @@ "# Both label and the data dict are optional parameters.\n", "# You can view, add or edit properties:\n", "print(front_axle.properties[\"label\"])\n", - "front_axle.properties[\"color\"] = \"grey\"\n", + "front_axle.properties[\"color\"] = \"light bluish grey\"\n", "\n", "\n", "# Create the second axle\n", @@ -143,7 +137,7 @@ "back_axle.properties.update(axles[\"32073\"])\n", "# Do not use = here, otherwise you'd overwrite existing properties.\n", "# Instead use update to have all entries added to properties\n", - "back_axle.properties[\"color\"] = \"grey\"\n", + "back_axle.properties[\"color\"] = \"light bluish grey\"\n", "# Viewing dicts in one line is not easy to read,\n", "# a better output comes with pretty print (pprint):\n", "pprint.pprint(back_axle.properties)" @@ -151,7 +145,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "id": "b4a8e8c8", "metadata": {}, "outputs": [ @@ -159,43 +153,47 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'category': 'wheel',\n", - " 'data source': 'https://www.bricklink.com/v2/catalog/catalogitem.page?P=2903c02#T=C',\n", + "{'category': 'rim',\n", + " 'data source': 'https://www.bricklink.com/v2/catalog/catalogitem.page?P=56904',\n", " 'delivery time [days]': 5,\n", - " 'diameter [mm]': 81.6,\n", - " 'item description': 'wheel 81,6',\n", - " 'item number': '2903c02',\n", - " 'label': 'front wheel',\n", - " 'mass [g]': 30.0,\n", + " 'diameter [mm]': 30.0,\n", + " 'environmental impact [kg CO2e /kg]': 32.06,\n", + " 'item description': 'Wheel 30mm D. x 14mm',\n", + " 'item number': 56904,\n", + " 'label': 'front rim',\n", + " 'mass [g]': 4.1,\n", " 'paint': 'glossy',\n", - " 'price [Euro]': 1.31,\n", - " 'related items': 2902,\n", + " 'price [Euro]': 0.01,\n", + " 'related items': 30699,\n", " 'surface': 'rough'}\n" ] } ], "source": [ "# Now wheels\n", - "with open(\"datasheets/wheels.json\") as json_file:\n", - " wheels = json.load(json_file)\n", + "# A wheel consists of a rim (Felge) and a tire (Reifen)\n", + "with open(\"datasheets/rims.json\") as json_file:\n", + " rims = json.load(json_file)\n", + "with open(\"datasheets/tires.json\") as json_file:\n", + " tires = json.load(json_file)\n", "# Adding the color here already as dict, and the surface as key-value argument.\n", "# Multiple of both parameters are supported, but only in this order.\n", "# front_wheel = LegoComponent(\n", "# 'front wheel', wheels['2903c02'], {'color':'yellow'},winter='true')\n", "\n", - "front_wheel = LegoComponent(\n", - " \"front wheel\", wheels[\"2903c02\"], surface=\"rough\", paint=\"glossy\"\n", - ")\n", - "pprint.pprint(front_wheel.properties)\n", + "front_rim = LegoComponent(\"front rim\", rims[\"56904\"], surface=\"rough\", paint=\"glossy\")\n", + "front_tire = LegoComponent(\"front tire\", tires[\"30699\"], winter=True)\n", + "pprint.pprint(front_rim.properties)\n", "\n", "# We included a clone function to both Lego classes, so you can easily\n", "# create duplicate objects. Passing the new label is optional\n", - "back_wheel = front_wheel.clone(\"back wheel\")" + "back_rim = front_rim.clone(\"back rim\")\n", + "back_tire = front_tire.clone(\"back tire\")" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "id": "25bd06c5", "metadata": {}, "outputs": [ @@ -203,7 +201,22 @@ "name": "stdout", "output_type": "stream", "text": [ - "front axle\n" + "front tire\n" + ] + }, + { + "ename": "KeyboardInterrupt", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[6], line 35\u001b[0m\n\u001b[0;32m 30\u001b[0m front_axle_assembly\u001b[38;5;241m.\u001b[39madd([front_wheel_assembly, front_axle])\n\u001b[0;32m 32\u001b[0m back_axle_assembly \u001b[38;5;241m=\u001b[39m LegoAssembly(\n\u001b[0;32m 33\u001b[0m AggregationLayer\u001b[38;5;241m.\u001b[39mASSEMBLY, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mback axle assembly\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 34\u001b[0m )\n\u001b[1;32m---> 35\u001b[0m \u001b[43mback_axle_assembly\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43madd\u001b[49m\u001b[43m(\u001b[49m\u001b[43m[\u001b[49m\u001b[43mback_axle_assembly\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mback_axle\u001b[49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32mc:\\Users\\Lamm\\Documents\\02_Areas\\Praktikum_Digitalisierung\\01_quality-kpi_dev\\functions\\classes.py:374\u001b[0m, in \u001b[0;36mLegoAssembly.add\u001b[1;34m(self, part)\u001b[0m\n\u001b[0;32m 372\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(part, \u001b[38;5;28mlist\u001b[39m):\n\u001b[0;32m 373\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m p \u001b[38;5;129;01min\u001b[39;00m part:\n\u001b[1;32m--> 374\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43madd\u001b[49m\u001b[43m(\u001b[49m\u001b[43mp\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 375\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 376\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(\n\u001b[0;32m 377\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mArgument should be of types \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mLegoAssembly\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m, \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 378\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mLegoComponent\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m or a list of them. \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 379\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mGot \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mtype\u001b[39m(part)\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m instead.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 380\u001b[0m )\n", + "File \u001b[1;32mc:\\Users\\Lamm\\Documents\\02_Areas\\Praktikum_Digitalisierung\\01_quality-kpi_dev\\functions\\classes.py:369\u001b[0m, in \u001b[0;36mLegoAssembly.add\u001b[1;34m(self, part)\u001b[0m\n\u001b[0;32m 356\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 357\u001b[0m \u001b[38;5;124;03mAdds either a Lego component, a subassembly or a (mixed) list of them to the\u001b[39;00m\n\u001b[0;32m 358\u001b[0m \u001b[38;5;124;03mcurrent assembly. Uses internal functions add_component() and add_assembly().\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 366\u001b[0m \u001b[38;5;124;03m instance, or a (mixed) list of them.\u001b[39;00m\n\u001b[0;32m 367\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 368\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(part, LegoComponent):\n\u001b[1;32m--> 369\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43madd_component\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpart\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 370\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(part, LegoAssembly):\n\u001b[0;32m 371\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39madd_assembly(part)\n", + "File \u001b[1;32mc:\\Users\\Lamm\\Documents\\02_Areas\\Praktikum_Digitalisierung\\01_quality-kpi_dev\\functions\\classes.py:310\u001b[0m, in \u001b[0;36mLegoAssembly.add_component\u001b[1;34m(self, component)\u001b[0m\n\u001b[0;32m 304\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(component, LegoComponent):\n\u001b[0;32m 305\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(\n\u001b[0;32m 306\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mArgument should be of type \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mLegoComponent\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m, \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 307\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mgot \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mtype\u001b[39m(component)\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m instead.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 308\u001b[0m )\n\u001b[1;32m--> 310\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_root_assembly\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39mcontains_uuid(component\u001b[38;5;241m.\u001b[39m_uuid):\n\u001b[0;32m 311\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mAssertionError\u001b[39;00m(\n\u001b[0;32m 312\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mThis assembly or a subassembly already contains \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 313\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mthe component with ID \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 314\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mcomponent\u001b[38;5;241m.\u001b[39m_uuid\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 315\u001b[0m )\n\u001b[0;32m 316\u001b[0m component\u001b[38;5;241m.\u001b[39m_parent \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\n", + "File \u001b[1;32mc:\\Users\\Lamm\\Documents\\02_Areas\\Praktikum_Digitalisierung\\01_quality-kpi_dev\\functions\\classes.py:439\u001b[0m, in \u001b[0;36mLegoAssembly.get_root_assembly\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 431\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 432\u001b[0m \u001b[38;5;124;03mReturns the root LegoAssembly of the current assembly by recursively\u001b[39;00m\n\u001b[0;32m 433\u001b[0m \u001b[38;5;124;03msearching up the tree until the top-most parent (the root) is found.\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 436\u001b[0m \u001b[38;5;124;03m The root LegoAssembly of the current LegoAssembly instance.\u001b[39;00m\n\u001b[0;32m 437\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 438\u001b[0m current_assembly \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\n\u001b[1;32m--> 439\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m current_assembly\u001b[38;5;241m.\u001b[39m_parent \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m 440\u001b[0m current_assembly \u001b[38;5;241m=\u001b[39m current_assembly\u001b[38;5;241m.\u001b[39m_parent\n\u001b[0;32m 441\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m current_assembly\n", + "\u001b[1;31mKeyboardInterrupt\u001b[0m: " ] } ], @@ -218,7 +231,7 @@ " assembly_method=\"stick together like lego blocks\",\n", ")\n", "# Add LegoComponents to the LegoAssembly, single or as list\n", - "front_wheel_assembly.add([front_wheel, front_axle])\n", + "front_wheel_assembly.add([front_rim, front_tire])\n", "# You can access the components of an assembly like this:\n", "print(front_wheel_assembly.components[1].properties[\"label\"])\n", "\n", @@ -230,7 +243,19 @@ "back_wheel_assembly = LegoAssembly(\n", " AggregationLayer.SUBASSEMBLY, \"back wheel assembly\"\n", " )\n", - "back_wheel_assembly.add([back_wheel, back_axle])" + "back_wheel_assembly.add([back_rim, back_tire])\n", + "\n", + "# Now combine wheels and axles\n", + "\n", + "front_axle_assembly = LegoAssembly(\n", + " AggregationLayer.ASSEMBLY, \"front axle assembly\"\n", + ")\n", + "front_axle_assembly.add([front_wheel_assembly, front_axle])\n", + "\n", + "back_axle_assembly = LegoAssembly(\n", + " AggregationLayer.ASSEMBLY, \"back axle assembly\"\n", + ")\n", + "back_axle_assembly.add([back_wheel_assembly, back_axle])" ] }, { @@ -465,7 +490,7 @@ "metadata": { "hide_input": false, "kernelspec": { - "display_name": ".venv", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -479,7 +504,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.12.6" }, "varInspector": { "cols": { @@ -509,11 +534,6 @@ "_Feature" ], "window_display": false - }, - "vscode": { - "interpreter": { - "hash": "386d359a8531ffdc4805ead3a16e7983e89a5ab7bba0cbec0e7ad9597b7a2b64" - } } }, "nbformat": 4,