Skip to main content

Magpylib Studio

Build and explore magpylib magnet designs visually — in VS Code, in a notebook, or in code. Name the numbers that matter, drag a slider, and the whole design follows, with the field computed exactly in milliseconds.

The Halbach ring of the marimo example in VS Code, half in the light theme and half in the dark: the objects and the steps that built them, the variables with their sliders, the 3D view with the field lines flowing through the bore, and the scene as code in the script tab.

The Halbach ring from docs/notebooks/halbach_ring.py: twelve magnets, one magnet and one pattern, and the field's lines flowing through the bore. Drag n and the ring rebuilds.

What you can do

  • Build a scene by hand. Add magnets, currents and sensors, group them, and move, turn and resize them in the 3D view.
  • Make it parametric. Name the numbers that matter — radius, gap, n — and write positions and sizes in terms of them. Drag a slider and everything follows. Values are SI unless you type a unit — 15 mm, 2 cm, 800 mT — or show the whole scene in mm and mT.
  • Pattern, don't copy. A ring of twenty magnets is one magnet and one "repeat around an axis" step, so changing the magnet changes them all.
  • See the field. Along a sensor path, as a map over a plane, or swept against a variable.
  • Undo anything. Every scene keeps the steps that built it; step back through them, or change an early one.
  • Switch to code and back. The script tab shows the scene as Python and applies your edits when you save. Export plain magpylib for anyone, or the scene as code to keep.
  • Let an AI assistant help. A coding agent can write the scene in code, read its field and sweep its variables, and hand it to you to open in the studio (see below).

Get started in VS Code

  1. Install the extension: search for Magpylib Studio in the Extensions view, or run code --install-extension magpylib.magpylib-studio-vscode.
  2. Open a folder, click the magpylib icon in the Activity Bar, choose Load Example Scene… and pick one from the gallery.
  3. The first time, it offers to Install the Engine (the Python side) for you. Nothing to set up beforehand.

More in the extension's guide.

Use it in a notebook

The same 3D view, in Jupyter, marimo, VS Code notebooks or Colab:

pip install "magpylib-studio[widget]"
import magpylib as magpy
from magpylib_studio.widget import SceneWidget

cube = magpy.magnet.Cuboid(polarization=(0, 0, 1), dimension=(0.01, 0.01, 0.01))
SceneWidget(cube)  # look around it; the pencil in its corner edits it
SceneWidget(cube, editable=True)  # or move, turn and resize it from the start

More in the notebook guide.

Write a scene in code

A scene is a plain magpylib function whose parameters are the variables:

from typing import Annotated

import magpylib as magpy
from magpylib_studio import Count, Length, duplicate_around, scene
from magpylib_studio.widget import SceneWidget


@scene
def ring(
    n: Annotated[int, Count(2, 60, slider=(4, 20))] = 10,
    radius: Annotated[float, Length(0.005, 0.08)] = 0.023,
):
    group = magpy.Collection(style_label="Ring")
    magnet = magpy.magnet.Cuboid(
        dimension=(0.01, 0.01, 0.01), polarization=(1, 0, 0), position=(radius, 0, 0)
    )
    group.add(magnet)
    duplicate_around(magnet, count=n, axis="z", spin=360 / n)
    return group


ring(n=12).getB((0, 0, 0))  # plain magpylib: real objects, a real field
ring.build().save(
    "ring.magpy.json"
)  # the document: n and radius are sliders in the studio
SceneWidget(ring, editable=True)  # the scene in a notebook, a slider per parameter

Called, it is magpylib. Built, it is the studio's document, every parameter a slider. More in the guide, and fourteen complete ones in magpylib_studio/examples, six of them with a marimo notebook in docs/notebooks: marimo edit docs/notebooks/coil_pair.py from a clone.

Let a coding agent write it

The package carries an Agent Skill that teaches coding agents — Claude Code, Codex, Copilot and others — to write scenes as such functions, read the field and sweep a variable, and hand you the result to open in the studio. In a project that depends on magpylib-studio:

uvx library-skills  # pick magpylib-studio; for Claude Code, install into .claude/skills

Install the Python package only

pip install magpylib-studio

Python 3.11 or newer, and magpylib 6.1.

Learn more

If you want to… Read
use the VS Code extension the extension's guide
use the 3D view in a notebook docs/guide/notebook.md
write scenes in code the guide
know how it works inside docs/architecture.md
contribute CONTRIBUTING.md
see where the project is going docs/roadmap.md
see what was decided, and why docs/decisions.md

License

BSD-3-Clause, like the other packages built on magpylib. See LICENSE.

Metadata

Release files for magpylib-studio 0.15.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for magpylib-studio 0.15.0
File Size Uploaded Provenance Actions
magpylib_studio-0.15.0.tar.gz 3.8 MB With provenance Details for magpylib_studio-0.15.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for magpylib-studio 0.15.0
File Interpreter ABI Platform Actions
magpylib_studio-0.15.0-py3-none-any.whl Python 3 none any Details for magpylib_studio-0.15.0-py3-none-any.whl

Total release size: 4.6 MB

Release files / magpylib_studio-0.15.0.tar.gz

Download URL magpylib_studio-0.15.0.tar.gz
Size 3.8 MB
Tags Source
SHA-256 checksum
How to use checksums
d0f3e35cf5fa5d829fc286bd41c2326ef44b90a21a77f53ec8dbf4e0f0dd0163
BLAKE2b-256 checksum
How to use checksums
4061ff7d7b4627884bc9e9cb3fb3ead7a7678a7620b034343dfe454403cd71d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / magpylib_studio-0.15.0-py3-none-any.whl

Download URL magpylib_studio-0.15.0-py3-none-any.whl
Size 753.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
481078408e290680e7b6009746ff78b357df53573f06376e4bb85a1a000266f4
BLAKE2b-256 checksum
How to use checksums
768952e78bb8039ee43b0df1453a68f1345b784b94a9200273cd66732e14cea7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Security for magpylib-studio 0.15.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for magpylib_studio-0.15.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page