Skip to content

Instantly share code, notes, and snippets.

@darrenwiens
Created June 2, 2023 22:32
Show Gist options
  • Save darrenwiens/fa21980bb72840f0d93931d3caab2022 to your computer and use it in GitHub Desktop.
Save darrenwiens/fa21980bb72840f0d93931d3caab2022 to your computer and use it in GitHub Desktop.
Draw Mr. PG with jupytercad
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "1fb21a77-b82a-4887-a86e-256926a15416",
"metadata": {},
"outputs": [
{
"data": {
"application/FCStd": "{\"commId\": \"601197df2b794742943ceb0034bfa885\"}",
"text/plain": [
"<jupytercad.notebook.cad_document.CadDocument at 0x1069e9c50>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from jupytercad import CadDocument\n",
"doc = CadDocument()\n",
"\n",
"hat_radius = 1.1\n",
"\n",
"asd = doc.add_sphere(\n",
" name=\"hatbody\",\n",
" radius=hat_radius,\n",
" position=[0,0,0]\n",
").add_box(\n",
" length=4,\n",
" width=4,\n",
" height=4,\n",
" position=[-2,-2,-4.2],\n",
" rotation_axis=[0,1,0],\n",
" rotation_angle=-10,\n",
").cut().add_box(\n",
" length=hat_radius*2,\n",
" width=hat_radius*2,\n",
" height=0.1,\n",
" position=[0,-hat_radius,0.2],\n",
" rotation_axis=[0,1,0],\n",
" rotation_angle=-10,\n",
").add_sphere(\n",
" radius=hat_radius*1.4\n",
").intersect(name=\"brim\")\n",
"\n",
"doc.add_sphere(\n",
" name=\"head\",\n",
" radius=1,\n",
" position=[0,0,0]\n",
")\n",
"\n",
"doc.add_cylinder(\n",
" name=\"nose\",\n",
" radius=0.2,\n",
" height=1.5,\n",
" rotation_axis=[0,1,0],\n",
" rotation_angle=90\n",
")\n",
"\n",
"doc.add_cylinder(\n",
" name=\"neck\",\n",
" radius=0.4,\n",
" height=2,\n",
" position=[0,0,-2]\n",
")\n",
"\n",
"doc.add_cylinder(\n",
" name=\"body\",\n",
" radius=1,\n",
" height=4,\n",
" position=[0,0,-5.3]\n",
")\n",
"\n",
"doc.add_cylinder(\n",
" name=\"rightupper\",\n",
" radius=0.4,\n",
" height=2.1,\n",
" position=[0,-0.5,-2],\n",
" rotation_axis=[1,0,0],\n",
" rotation_angle=-225\n",
").add_cylinder(\n",
" name=\"rightlower\",\n",
" radius=0.4,\n",
" height=2.9,\n",
" position=[0,0,-5],\n",
" rotation_axis=[1,0,0],\n",
" rotation_angle=45\n",
")\n",
"\n",
"doc.add_cylinder(\n",
" name=\"lefttupper\",\n",
" radius=0.4,\n",
" height=2.1,\n",
" position=[0,0.5,-2],\n",
" rotation_axis=[1,0,0],\n",
" rotation_angle=-100\n",
").add_cylinder(\n",
" name=\"leftlower\",\n",
" radius=0.4,\n",
" height=2,\n",
" position=[0,2.3,-2.2],\n",
" rotation_axis=[1,0,0],\n",
" rotation_angle=-30\n",
")\n",
"\n",
"display(doc)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5784a35d-8677-490d-b789-e7013f36ad21",
"metadata": {},
"outputs": [],
"source": []
}
],
"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.11.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment