{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import cadquery as cq\n", "\n", "# 1. Establishes a workplane that an object can be built on.\n", "# 1a. Uses the named plane orientation \"front\" to define the workplane, meaning\n", "# that the positive Z direction is \"up\", and the negative Z direction\n", "# is \"down\".\n", "# 2. Creates a plain box to base future geometry on with the box() function.\n", "# 3. Selects the top-most Z face of the box.\n", "# 4. Creates a new workplane and then moves and rotates it with the\n", "# transformed function.\n", "# 5. Creates a for-construction rectangle that only exists to use for placing\n", "# other geometry.\n", "# 6. Selects the vertices of the for-construction rectangle.\n", "# 7. Places holes at the center of each selected vertex.\n", "# 7a. Since the workplane is rotated, this results in angled holes in the face.\n", "result = cq.Workplane(\"front\").box(4.0, 4.0, 0.25).faces(\">Z\") \\\n", " .workplane() \\\n", " .transformed(offset=(0, -1.5, 1.0), rotate=(60, 0, 0)) \\\n", " .rect(1.5, 1.5, forConstruction=True).vertices().hole(0.25)\n", "\n", "# Displays the result of this script\n", "show_object(result)\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.14" } }, "nbformat": 4, "nbformat_minor": 1 }