Skip to content

Commit

Permalink
jupyter_tools: use uuid for unique shape id
Browse files Browse the repository at this point in the history
  • Loading branch information
victorpoughon committed Jan 21, 2025
1 parent f67c54d commit fd52978
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/build123d/jupyter_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# pylint: disable=no-name-in-module
from json import dumps
import os
import uuid
from string import Template
from typing import Any, Dict, List
from IPython.display import HTML
Expand Down Expand Up @@ -92,7 +93,7 @@ def shape_to_html(shape: Any) -> HTML:
)

# A new div with a unique id, plus the JS code templated with the id
div_id = "shape-" + str(id(shape))
div_id = 'shape-' + uuid.uuid4().hex[:8]
code = Template(TEMPLATE_JS).substitute(data=dumps(payload), div_id=div_id, ratio=0.5)
html = HTML(f"<div id={div_id}></div><script>{code}</script>")

Expand Down

0 comments on commit fd52978

Please sign in to comment.