Playground
planex2d Python playground
Write planex2d code and see what it prints and draws, in an editor like VS Code. The code runs in this tab with Pyodide/ngapp, every run from scratch, and a share link carries the code itself. Nothing is uploaded.
- Code stays in your browser
- Share links carry the code
- The planex2d documentation
Write on the left and press Run or Ctrl+Enter; what the code prints and draws shows on the right. Share copies a link that carries the code; a link opened here loads its code without running it, so you can read it first.
What the playground does
It runs planex2d code in your browser and shows what the code prints and draws.
planex2d is a Python library for exact 2D geometry: outlines from lines, arcs, circles and splines, Boolean operations, offsets and fillets, sketches with geometric constraints and driving dimensions, measurements, and the DXF, SVG and planar STEP files that carry them. The playground lets you try all of it without installing anything. It answers questions a drawing program leaves open, such as the moments of inertia of an odd profile, the thinnest wall of a part or the area that two outlines share, and it shows the result as a drawing you can zoom and hover. A link carries the code, so a question about a shape can be shared together with the code that answers it.
What a run shows
Every run starts from scratch, as a script: a fresh namespace, fresh automatic ids, and the code from the first line to the last. What it prints, its warnings and its errors appear on the right in the order they come, an error with the line it stopped at, which the editor marks. px.Plot draws with plotly, so the ids of the edges show on hover; matplotlib figures appear when the code calls plt.show(). When the last line is a value, it is shown too: a planex2d object is drawn, anything else printed.
What the code can import
The Python standard library, planex2d, numpy, plotly, ezdxf and svgelements load with the page. matplotlib, scipy and shapely load the first time the code imports them. Every package is pinned to one version, so the same code gives the same result tomorrow; any other import is reported before the code runs.
Sharing
Share puts the code, compressed, into the link after the # sign, together with the planex2d version it was written for. A link of a few dozen lines is a few hundred characters long; a link over 2,000 characters gets a warning, since some chat apps cut links that long. A shared link loads its code into the editor without running it, so you can read it first.
How the playground works
A small page around the planex2d Python library. It runs the same code you get with pip install planex2d, compiled to WebAssembly and loaded with Pyodide/ngapp.
- Load
The page loads Python and planex2d into this tab. Your browser keeps both in its cache, so later visits start faster.
- Write
The editor is Monaco, the editor of VS Code. It keeps your code in this browser between visits.
- Run
Run or Ctrl+Enter sends the code to Python in this tab, which runs it and shows its output on the right.
- Share
Share copies a link that carries the code. Nothing is stored anywhere else.
Run it on your machine
The same code runs in Python on your machine. Install planex2d and see the documentation for everything it can do. Outside the playground, px.Plot draws with matplotlib unless it is given backend="plotly".
$ pip install planex2d
Privacy
Your code is not uploaded. It runs in this tab and is kept in this browser only. A shared link carries the code after the # sign, the part of a link that browsers never send to a server. Python, planex2d and its packages come from public package servers (jsDelivr and PyPI). See the privacy notice.
Limits
- The playground has planex2d's core. The OpenCASCADE bindings, planex2d-occ, do not run in the browser yet, so nothing in 3D.
- A run cannot be interrupted. Stop starts Python again, which takes a few seconds once its packages are cached.
- In the browser, planex2d runs in one thread, so a long computation takes longer than in Python on your machine.
- Something does not work? Open an issue on GitHub with a share link if you can.
Questions and answers
Is my code uploaded?
No. The code runs in this browser tab, with Python (Pyodide) and planex2d loaded from jsDelivr and PyPI, and stays in your browser. A share link carries the code after the # sign, a part of a link that browsers never send to a server.
What can I import?
The Python standard library, planex2d, numpy, plotly, ezdxf and svgelements, and matplotlib, scipy and shapely, which load the first time the code imports them. Every package is pinned to one version, so a shared link keeps giving the same result.
How does a run work?
Every run starts the code from scratch, as a script, with fresh automatic ids, so a shared link gives the same output and the same ids for anyone. What the code prints and draws appears on the right; px.Plot draws with plotly, so the ids of the edges show on hover, and a value on the last line is shown as well.
Can I use OpenCASCADE here?
Not yet. The playground has planex2d's core: geometry, sketches and constraints, Boolean operations, offsets, measuring and the DXF, SVG and planar STEP files. The OpenCASCADE bindings, planex2d-occ, do not run in the browser yet.
The tools on planex2d.org
Every tool runs on the planex2d library, in your browser.
-
-
Converters
Many DXF, SVG, STEP and BREP files in, one format out, all saved at once.
-
Calculator
Area, centroid, second moments and section moduli of a drawing, and the mass of a sheet part.
-
Contour checker
Open contours, gaps, doubled lines and tiny edges in DXF, SVG and STEP drawings, marked and repaired.
-
Nesting
Plies and flat parts placed on a roll for the shortest length, with the fiber direction kept.
The planex2d documentation shows the library behind the tools, and the homepage lists everything on planex2d.org.