{ "cells": [ { "cell_type": "markdown", "id": "3193862edc43da14", "metadata": {}, "source": [ "# Placement of parts and objects\n", "\n", "Placement of every object in adapy can be controlled using the Placement object." ] }, { "cell_type": "code", "execution_count": 1, "id": "2910341458c85e3c", "metadata": { "ExecuteTime": { "end_time": "2025-03-17T09:21:20.613963Z", "start_time": "2025-03-17T09:21:19.474661Z" } }, "outputs": [], "source": [ "import ada" ] }, { "cell_type": "code", "execution_count": 2, "id": "750efee21a7fc662", "metadata": { "ExecuteTime": { "start_time": "2025-03-17T09:21:20.619735Z" }, "jupyter": { "is_executing": true } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\AibelProgs\\code\\adapy\\.pixi\\envs\\tests\\Lib\\site-packages\\h5py\\__init__.py:36: UserWarning: h5py is running against HDF5 (1, 14, 4) when it was built against (1, 14, 4, 3), this may cause problems\n", " _warn((\"h5py is running against HDF5 {0} when it was built against {1}, \"\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bm = ada.Beam('bm1', (0,0,0), (1,0,0), 'IPE300')\n", "other_beams = []\n", "for i, angle in enumerate([45, 90, 135, 180], start=2):\n", " bm2 = bm.copy_to(f\"bm{i}\", (0,0,i-1), (1,0,i-1))\n", " bm2.placement = bm2.placement.rotate((0,0,1), angle)\n", " other_beams.append(bm2)\n", "p = ada.Part('MyPart') / (bm, *other_beams)\n", "p.show(embed_glb=True)" ] }, { "cell_type": "code", "execution_count": 3, "id": "a168e4b2b24ad4d4", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "w = 5\n", "pl = ada.Plate('pl1', [(0,0), (w,0), (w,w), (0,w)], 0.01)\n", "beams = ada.Beam.array_from_list_of_coords(pl.poly.points3d,'IPE300', make_closed=True)\n", "p = ada.Part('myPart') / (pl, *beams)\n", "p.show(embed_glb=True)" ] }, { "cell_type": "code", "execution_count": 4, "id": "3d694b46-81d0-46fb-b386-92ebb7d7793b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p.placement = p.placement.rotate((0,0,1), 45)\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 }