Example plugin for BREP CAD
Repo mmiscool/BREP.io-pluginExample, read from GitHub 7 h ago. mmiscool has not joined Take My Repo.
mmiscool/BREP.io-pluginExample is a public repo on GitHub by mmiscool. Example plugin for BREP CAD. It declares the MIT license on GitHub. It is written mainly in JavaScript, has 1 stars and last changed on 2025-09-25. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-23.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
This document explains how to build third‑party plugins for the BREP CAD application. It covers the plugin entrypoint, the app object you receive (including app.BREP), how to register new features, the structure of a feature class, the supported parameter schema types, and the small UI hooks you can use.
If you just want the TL;DR: your repo must contain a plugin.js ES module that exports a function. In that function, call app.registerFeature(YourFeatureClass) and optionally add UI via app.addToolbarButton(...) or app.addSidePanel(...).
You can fork this repo as a starting point for your plugin. After you have forked it simply edit plugin.js.
See also: the BREP application README: https://github.com/mmiscool/BREP/blob/master/README.md
plugin.js in the repo (or subdirectory when the URL includes it).app, an object that provides:BREP: access to BREP modeling classes/utilities (solids/primitives/CSG helpers/THREE instance).viewer: the live viewer instance (scene, part history, toolbar, etc.).registerFeature(FeatureClass): register a new modeling feature.addToolbarButton(label, title, onClick): add a toolbar button.addSidePanel(title, content): add a side panel section to the sidebar.Where these come from in the app: see src/plugins/pluginManager.js (builds the app object) and src/UI/viewer.js (viewer API).
https://github.com/USER/REPOhttps://github.com/USER/REPO/tree/BRANCHhttps://github.com/USER/REPO/tree/BRANCH/sub/dirplugin.js at that path, tries GitHub Raw on ref (or main/master), and falls back to jsDelivr CDN.plugin.js are rewritten to absolute URLs against your repo base, so you can structure your plugin across multiple files.import x from 'some-npm-package') are NOT resolved. Use relative imports within your repo, or explicit URL imports if you need an external dependency.Place a plugin.js at the repo path. Export either a default function or an install function. Both receive app.
Example minimal entrypoint (from this repo):
// plugin.js
import { PrimitiveSphereFeaturePlugin } from './exampleFeature.js';
export default function install(app) {
// Make the app (and BREP) available to the feature class
PrimitiveSphereFeaturePlugin.setup(app);
// Optional: small UI hooks
app.addToolbarButton('🧩', 'Hello', () => {
console.log('Hello from plugin');
console.log('This is the context passed in to the plugin.', app);
alert('Yay');
});
app.addSidePanel('Plugin Panel', () => {
const div = document.createElement('div');
div.textContent = 'This was added by a plugin.';
return div;
});
// Register your feature so users can add it
app.registerFeature(PrimitiveSphereFeaturePlugin);
}
app Objectapp is constructed by the application when your plugin loads:
app.BREP — The modeling toolkit and a shared THREE instance. This includes:THREE, Solid, Face, Edge, VertexCube, Sphere, Cylinder, Cone, Torus, PyramidSweep, ExtrudeSolid, ChamferSolid, FilletSolidapplyBooleanOperation(partHistory, baseSolid, booleanParam, featureID), MeshToBrep, MeshRepairerapp.viewer — The live viewer. Useful bits:viewer.scene — A Three.js scene containing the model objects.viewer.partHistory — The history and feature pipeline (see below).viewer.addToolbarButton(label, title, onClick) — Add a custom button.viewer.addPluginSidePanel(title, content) — Add a side panel; content can be an element, a function that returns an element, or a string.app.registerFeature(FeatureClass) — Register a feature so users can add it from the UI/history. The app marks it as plugin‑provided and prefixes names with a plug icon.Call app.registerFeature(YourFeatureClass). The app will:
fromPlugin = true).featureShortName and featureName with a plug icon in UI.viewer.partHistory.newFeature('Your Name or ShortName').Every feature is a small class with three static fields and two instance fields, plus a run() method.
featureShortName — Short code shown in menus (e.g., E, P.CU).featureName — Human friendly name.inputParamsSchema — Describes inputs; the UI is auto‑generated from this.this.inputParams — Filled with sanitized values before run() is called.this.persistentData — Your scratchpad; survives across runs of this feature.async run(partHistory) — Build/update geometry. Return either:{ added: [...], removed: [...] } for fine‑grained control.Typical flow inside run() for geometry‑creating features:
app.BREP classes.bakeTRS) and call visualize() to create display geometry and helper edges.BREP.applyBooleanOperation(partHistory, base, this.inputParams.boolean, this.inputParams.featureID).Important conventions:
this.inputParams.featureID (e.g., pass name: featureID to constructors). This enables referencing them in later features.this.persistentData to speed up subsequent runs.Define static inputParamsSchema = { ... }. The app uses this to:
run().Supported field types and options:
string
default_value: stringhint?: stringnumber
default_value: number | string — Users can type math expressions. Numbers are evaluated against the global Expressions manager, so x * 2 is allowed if x is defined.min?, max?, step?: number or stringhint?: stringboolean
default_value: booleanoptions
options: string[] — Fixed list of valuesdefault_value: stringbutton
label?: stringactionFunction?: (ctx) => void | Promise<void> — Called on click. ctx includes { featureID, key, viewer, partHistory, feature, params, schemaDef }.file
accept?: string — e.g., .png,image/pngtransform
default_value: { position: [x,y,z], rotationEuler: [rx,ry,rz], scale?: [sx,sy,sz] }inputParams.reference_selection
selectionFilter: ["SOLID" | "FACE" | "EDGE" | "SKETCH" | "PLANE", ...]multiple: boolean — single value (string) or array of strings.default_value: string | string[] | nullrun(), the app resolves the names into actual objects where possible; this.inputParams[key] will be an array of objects for multiple: true or a single‑element array for single select.boolean_operation
{ operation: 'NONE'|'UNION'|'SUBTRACT'|'INTERSECT', targets: (string|object)[] }.biasDistance, offsetCoplanarCap, offsetDistance for advanced subtract behavior.BREP.applyBooleanOperation(...) for robust, normalized handling.app.BREPapp.BREP is already imported from the application, so you must NOT import your own copy of Three.js or the BREP library. Using the shared instance avoids duplicate constructors and broken instanceof checks.
Common patterns:
const { BREP } = app;
// Primitives
const sphere = new BREP.Sphere({ r: 5, resolution: 32, name: 'MySphere' });
sphere.visualize();
// Sweeps/Extrudes
const sweep = new BREP.Sweep({ face: someFace, distance: 10, name: 'MyExtrude' });
sweep.visualize();
// CSG helper
const result = await BREP.applyBooleanOperation(partHistory, sphere, { operation: 'UNION', targets: [otherSolid] }, 'Feat123');
// → { added: [Solid], removed: [Solid, ...] }
app.BREP exactlyThis repo’s example passes the app object into the feature class via a static setup(app) method, and the feature reads the shared BREP instance from there:
// exampleFeature.js
export class PrimitiveSphereFeaturePlugin {
static app = null;
static setup(app) { this.app = app; }
async run(partHistory) {
const BREP = this.constructor.app.BREP; // shared instance from the host app
const sphere = new BREP.Sphere({ r: 5, resolution: 32, name: 'FeatureID' });
sphere.visualize();
return await BREP.applyBooleanOperation(partHistory, sphere, this.inputParams.boolean, this.inputParams.featureID);
}
}
Alternative patterns also work, such as capturing once at module scope (let BREP; export default (app) => { BREP = app.BREP; }) or destructuring on demand (const { BREP } = app). Always use the provided app.BREP rather than importing your own copy.
This section shows the actual files in this repo and how the feature gets access to app.BREP.
// plugin.js
import { PrimitiveSphereFeaturePlugin } from './exampleFeature.js';
export default (app) => {
// Provide the app (which contains BREP) to the feature class
PrimitiveSphereFeaturePlugin.setup(app);
// Optional UI examples
app.addToolbarButton('🧩', 'Hello', () => {
console.log('Hello from plugin');
console.log('This is the context passed in to the plugin.', app);
alert('Yay');
});
app.addSidePanel('Plugin Panel', () => {
const div = document.createElement('div');
div.textContent = 'This was added by a plugin.';
return div;
});
// Register the feature
app.registerFeature(PrimitiveSphereFeaturePlugin);
};
// exampleFeature.js
const inputParamsSchema = {
featureID: { type: 'string', default_value: null, hint: 'Unique identifier for the feature' },
radius: { type: 'number', default_value: 5, hint: 'Radius of the sphere' },
resolution: { type: 'number', default_value: 32, hint: 'Base segment count (longitude). Latitude segments are derived from this.' },
transform: { type: 'transform', default_value: { position: [0, 0, 0], rotationEuler: [0, 0, 0], scale: [1, 1, 1] }, hint: 'Position, rotation, and scale' },
boolean: { type: 'boolean_operation', default_value: { targets: [], operation: 'NONE' }, hint: 'Optional boolean operation with selected solids' },
};
export class PrimitiveSphereFeaturePlugin {
static featureShortName = 'S.p';
static featureName = 'Primitive Sphere';
static inputParamsSchema = inputParamsSchema;
static app = null;
static setup(app) { this.app = app; }
constructor() {
this.inputParams = {};
this.persistentData = {};
}
async run(partHistory) {
const { radius, resolution, featureID } = this.inputParams;
const BREP = this.constructor.app.BREP; // Access BREP from the app provided during setup
const sphere = await new BREP.Sphere({ r: radius, resolution, name: featureID });
try {
if (this.inputParams.transform) {
sphere.bakeTRS(this.inputParams.transform);
}
} catch (_) {}
sphere.visualize();
return await BREP.applyBooleanOperation(partHistory || {}, sphere, this.inputParams.boolean, featureID);
}
}
Note: the loader will prefix plugin‑provided names in the UI with a plug icon. To avoid confusion with built‑in features, pick a unique featureShortName.
From toolbar buttons or side panels you can add features directly:
const ph = app.viewer.partHistory;
// Either the long name or short name works; match your class statics.
const feature = await ph.newFeature('Primitive Sphere'); // or 'S.p'
feature.inputParams.radius = 20;
await ph.runHistory();
Internally, this uses the Feature Registry (src/FeatureRegistry.js) to find your class and apply default values from inputParamsSchema.
app.addToolbarButton(label, title, onClick) — Adds a small labeled button to the main toolbar.app.addSidePanel(title, content) — Inserts a collapsible section in the sidebar. content may be:HTMLElementHTMLElement (async allowed)<pre>)Plugin side panels appear before the Display Settings panel.
your-plugin-repo/
plugin.js # entrypoint (required)
exampleFeature.js # a feature class
plugin.js can import your own files via relative paths:
import { PrimitiveSphereFeaturePlugin } from './exampleFeature.js';
export default (app) => {
PrimitiveSphereFeaturePlugin.setup(app);
app.registerFeature(PrimitiveSphereFeaturePlugin);
};
.visualize() on solids you generate before returning them.featureID for easy referencing.this.persistentData for caches/intermediate results to speed reruns.app.BREP.THREE over importing your own Three.js.BREP.applyBooleanOperation(...)..visualize() on your BREP solids/faces? Are you naming outputs correctly?reference_selection fields, the app resolves names to objects at run time. Ensure the referenced objects exist and are named.mmiscool/BREP.io-pluginExample is a public repo on GitHub by mmiscool. Example plugin for BREP CAD.
It declares the MIT license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2025-09-25. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
BREP kernel from scratch using triangle meshes with BREP type topology
Basic Interpreter for the ESP8266

A tool to write JS libraries using AI. The first and only tool that is using ASTs to perform surgical changes to existing code files with out mangling the code. https://aicoderproject.com/
Project to run FreeCAD in a cloud environment accessible via a web browser in a cloud environment.

Record your screen, trim the clips and export single video file with result. No nonsense screen capture and recording to make quick videos. Zero dependencies. No build system. Just raw html, js and css you can throw on any old server.