{ "cells": [ { "cell_type": "markdown", "id": "3dacd84e4e8e39b9", "metadata": {}, "source": [ "# Modelling with adapy" ] }, { "cell_type": "code", "execution_count": 15, "id": "initial_id", "metadata": { "ExecuteTime": { "end_time": "2025-03-14T09:47:50.527331Z", "start_time": "2025-03-14T09:47:50.524270Z" } }, "outputs": [], "source": [ "import ada" ] }, { "cell_type": "markdown", "id": "5a3bfdef-8d31-46e9-8c21-ac431a38f23a", "metadata": {}, "source": [ "## Basic Primitives\n", "First lets look at the various primitives that adapy can model" ] }, { "cell_type": "code", "execution_count": 16, "id": "8caeb99f00c2b95a", "metadata": { "ExecuteTime": { "end_time": "2025-03-14T09:47:51.223296Z", "start_time": "2025-03-14T09:47:51.152144Z" } }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bm = ada.Beam('bm1', (0,0,0), (1,0,0), 'IPE300')\n", "bm.show(embed_glb=True)" ] }, { "cell_type": "code", "execution_count": 17, "id": "f37a9af66ff0a156", "metadata": { "ExecuteTime": { "end_time": "2025-03-14T09:48:39.231500Z", "start_time": "2025-03-14T09:48:39.162499Z" } }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pl = ada.Plate('pl1', [(0,0), (1,0), (1,1), (0,1)], 0.01)\n", "pl.show(embed_glb=True)" ] }, { "cell_type": "code", "execution_count": 18, "id": "830fd437-f098-4c0a-aa4d-bfaeff497441", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "box = ada.PrimBox(\"box1\", (0,0,0), (1,1,1))\n", "box.show(embed_glb=True)" ] }, { "cell_type": "code", "execution_count": 19, "id": "fa65c8b1-a388-4e45-93ce-e13c6fedf01f", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cyl = ada.PrimCyl(\"cyl1\", (0,0,0), (0,0,1), 0.1)\n", "cyl.show(embed_glb=True)" ] }, { "cell_type": "markdown", "id": "e1c82324-2450-4fcc-8612-594455277867", "metadata": {}, "source": [ "There are more primitives, but it's easier to access those by simply printing the classes accessible from `ada.` starting with `Prim` in addition to the typical structural items Beam, Plate, Pipe etc..." ] }, { "cell_type": "code", "execution_count": 27, "id": "8fa2cbf8-6cb8-431e-9fa8-be36485fd5a8", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['ArcSegment',\n", " 'Assembly',\n", " 'BM_N',\n", " 'Beam',\n", " 'BeamRevolve',\n", " 'BeamSweep',\n", " 'BeamTapered',\n", " 'Bolts',\n", " 'Boolean',\n", " 'Counter',\n", " 'CurvePoly2d',\n", " 'CurveRevolve',\n", " 'Direction',\n", " 'FEM',\n", " 'Group',\n", " 'Instance',\n", " 'LineSegment',\n", " 'Material',\n", " 'Node',\n", " 'PL_N',\n", " 'Part',\n", " 'Pipe',\n", " 'PipeSegElbow',\n", " 'PipeSegStraight',\n", " 'Placement',\n", " 'Plate',\n", " 'PlateCurved',\n", " 'Point',\n", " 'PrimBox',\n", " 'PrimCone',\n", " 'PrimCyl',\n", " 'PrimExtrude',\n", " 'PrimRevolve',\n", " 'PrimSphere',\n", " 'PrimSweep',\n", " 'Section',\n", " 'Shape',\n", " 'TYPE_CHECKING',\n", " 'Transform',\n", " 'Units',\n", " 'User',\n", " 'Wall',\n", " 'Weld',\n", " 'annotations',\n", " 'api',\n", " 'base',\n", " 'cache',\n", " 'comms',\n", " 'config',\n", " 'configure_logger',\n", " 'core',\n", " 'deprecated',\n", " 'fem',\n", " 'from_fem',\n", " 'from_fem_res',\n", " 'from_genie_xml',\n", " 'from_ifc',\n", " 'from_sesam_cc',\n", " 'from_step',\n", " 'geom',\n", " 'materials',\n", " 'occ',\n", " 'os',\n", " 'pathlib',\n", " 'sections',\n", " 'set_jupyter_part_renderer',\n", " 'visit',\n", " 'warnings']" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "[x for x in dir(ada) if not x.startswith(\"__\")]" ] }, { "cell_type": "markdown", "id": "60a1977a-1046-498b-a4c8-dbfb7a7ec61a", "metadata": {}, "source": [ "## Combining objects into parts and assemblies\n", "\n", "In ada-py the Part and Assembly objects are used to define the hierarchy of elements. Assembly is the top-level object referenced only once per project, while the Part object is used to representany hierarchical level underneath the Assembly.\n", "\n", "The way Ada-py defines hierarchies can be used either by \n", "\n", "\n", "```python\n", "bm = ada.Beam(\"bm1\", (0,0,0), (1,0,0), 'IPE300')\n", "p = ada.Part('myPart')\n", "p.add_object(bm)\n", "```\n" ] }, { "cell_type": "code", "execution_count": 30, "id": "839f008b-e916-45e3-b865-84554718065c", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bm = ada.Beam(\"bm1\", (0,0,0), (1,0,0), 'IPE300')\n", "pl = ada.Plate('pl1', [(0,0), (1,0), (1,1), (0,1)], 0.01)\n", "p = ada.Part('myPart')\n", "p.add_object(bm)\n", "p.add_object(pl)\n", "p.show(embed_glb=True)" ] }, { "cell_type": "markdown", "id": "1b1dd11e-78e8-4413-9110-7da5361020f8", "metadata": {}, "source": [ "Or you can use \"/\" (inspired by how pathlib concatenates paths). " ] }, { "cell_type": "code", "execution_count": 31, "id": "505aa44e-2bbd-47bc-a661-15ae31727ce7", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bm = ada.Beam(\"bm1\", (0,0,0), (1,0,0), 'IPE300')\n", "pl = ada.Plate('pl1', [(0,0), (1,0), (1,1), (0,1)], 0.01)\n", "p = ada.Part('MyPart') / (bm, pl)\n", "p.show(embed_glb=True)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.9" } }, "nbformat": 4, "nbformat_minor": 5 }