-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ead9fe
commit c60606b
Showing
3 changed files
with
193 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# Ignore content/data folder | ||
content/data/ | ||
|
||
*.bundle.* | ||
lib/ | ||
node_modules/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 26, | ||
"metadata": { | ||
"trusted": true | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Requirement already satisfied: jsonschema in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (4.23.0)\n", | ||
"Requirement already satisfied: networkx in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (3.3)\n", | ||
"Requirement already satisfied: numpy in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (1.26.4)\n", | ||
"Requirement already satisfied: scipy in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (1.14.0)\n", | ||
"Requirement already satisfied: pythreejs in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (2.4.2)\n", | ||
"Requirement already satisfied: attrs>=22.2.0 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from jsonschema) (23.2.0)\n", | ||
"Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from jsonschema) (2023.12.1)\n", | ||
"Requirement already satisfied: referencing>=0.28.4 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from jsonschema) (0.35.1)\n", | ||
"Requirement already satisfied: rpds-py>=0.7.1 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from jsonschema) (0.19.1)\n", | ||
"Requirement already satisfied: ipywidgets>=7.2.1 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from pythreejs) (8.1.3)\n", | ||
"Requirement already satisfied: ipydatawidgets>=1.1.1 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from pythreejs) (4.3.5)\n", | ||
"Requirement already satisfied: traitlets in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from pythreejs) (5.14.3)\n", | ||
"Requirement already satisfied: traittypes>=0.2.0 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from ipydatawidgets>=1.1.1->pythreejs) (0.2.1)\n", | ||
"Requirement already satisfied: comm>=0.1.3 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from ipywidgets>=7.2.1->pythreejs) (0.2.2)\n", | ||
"Requirement already satisfied: ipython>=6.1.0 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from ipywidgets>=7.2.1->pythreejs) (8.18.0)\n", | ||
"Requirement already satisfied: widgetsnbextension~=4.0.11 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from ipywidgets>=7.2.1->pythreejs) (4.0.11)\n", | ||
"Requirement already satisfied: jupyterlab-widgets~=3.0.11 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from ipywidgets>=7.2.1->pythreejs) (3.0.11)\n", | ||
"Requirement already satisfied: decorator in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (5.1.1)\n", | ||
"Requirement already satisfied: jedi>=0.16 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.19.1)\n", | ||
"Requirement already satisfied: matplotlib-inline in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.1.7)\n", | ||
"Requirement already satisfied: prompt-toolkit!=3.0.37,<3.1.0,>=3.0.30 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (3.0.36)\n", | ||
"Requirement already satisfied: pygments>=2.4.0 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (2.18.0)\n", | ||
"Requirement already satisfied: stack-data in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.6.3)\n", | ||
"Requirement already satisfied: pexpect>4.3 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (4.9.0)\n", | ||
"Requirement already satisfied: parso<0.9.0,>=0.8.3 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from jedi>=0.16->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.8.4)\n", | ||
"Requirement already satisfied: ptyprocess>=0.5 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from pexpect>4.3->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.7.0)\n", | ||
"Requirement already satisfied: wcwidth in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from prompt-toolkit!=3.0.37,<3.1.0,>=3.0.30->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.2.13)\n", | ||
"Requirement already satisfied: executing>=1.2.0 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from stack-data->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (2.0.1)\n", | ||
"Requirement already satisfied: asttokens>=2.1.0 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from stack-data->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (2.4.1)\n", | ||
"Requirement already satisfied: pure-eval in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from stack-data->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (0.2.3)\n", | ||
"Requirement already satisfied: six>=1.12.0 in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (from asttokens>=2.1.0->stack-data->ipython>=6.1.0->ipywidgets>=7.2.1->pythreejs) (1.16.0)\n", | ||
"Note: you may need to restart the kernel to use updated packages.\n", | ||
"Note: you may need to restart the kernel to use updated packages.\n", | ||
"Requirement already satisfied: compas_notebook in /home/petras/anaconda3/envs/iass/lib/python3.12/site-packages (0.6.1)\n", | ||
"Note: you may need to restart the kernel to use updated packages.\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"%pip install jsonschema networkx numpy scipy pythreejs\n", | ||
"%pip install compas>=2.0.0 --no-deps\n", | ||
"%pip install compas_notebook --no-deps" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Working with Compas Session Files" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 27, | ||
"metadata": { | ||
"trusted": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import compas\n", | ||
"from compas.geometry import Box\n", | ||
"import pathlib\n", | ||
"\n", | ||
"box = Box(1, 1, 1)\n", | ||
"mesh = box.to_mesh().subdivided(k=4)\n", | ||
"mesh.translate([2, 0, 0])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Serialize Dictionary to Session File" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 28, | ||
"metadata": { | ||
"scrolled": true, | ||
"trusted": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Define the path to the data folder and the JSON file\n", | ||
"data_folder = pathlib.Path.cwd() / \"data\"\n", | ||
"if not data_folder.exists():\n", | ||
" data_folder.mkdir(parents=True)\n", | ||
"\n", | ||
"# Serialize the geometry to JSON and save it to the filepath\n", | ||
"session = {\"box\": box, \"mesh\": mesh}\n", | ||
"file_path = data_folder / \"session.json\"\n", | ||
"compas.json_dump(session, file_path)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Deserialize Session File" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 29, | ||
"metadata": { | ||
"scrolled": true, | ||
"trusted": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"session = compas.json_load(file_path)\n", | ||
"box = session[\"box\"]\n", | ||
"mesh = session[\"mesh\"]\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Vizualize Deserialized Session File" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 30, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "8c0b059de054424ab30fb1b844b7285c", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"VBox(children=(HBox(children=(Button(icon='search-plus', layout=Layout(height='32px', width='48px'), style=But…" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"from compas_notebook.viewer import Viewer\n", | ||
"from compas.colors import Color\n", | ||
"\n", | ||
"viewer = Viewer()\n", | ||
"viewer.scene.add(box, color=Color.red())\n", | ||
"viewer.scene.add(mesh, color=Color.green())\n", | ||
"viewer.show()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "iass", | ||
"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.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |