bambu-printer-mcp 1.1.97 → 1.1.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cad/contracts.js +1 -1
- package/dist/design-guidance.d.ts +1 -1
- package/dist/design-guidance.js +3 -0
- package/dist/index.js +48 -3
- package/dist/refusal.d.ts +17 -1
- package/dist/refusal.js +14 -3
- package/dist/slicer/filament-feed.d.ts +61 -0
- package/dist/slicer/filament-feed.js +99 -0
- package/package.json +2 -2
- package/src/cad/contracts.ts +1 -1
- package/src/design-guidance.ts +3 -0
- package/src/index.ts +45 -4
- package/src/refusal.ts +21 -3
- package/src/slicer/filament-feed.ts +116 -0
package/dist/cad/contracts.js
CHANGED
|
@@ -390,7 +390,7 @@ Measure a scan once, before designing from it: one check run (role: "check", mod
|
|
|
390
390
|
Fit reference workflow: return load_scan("scan", source_units="m", up_axis="y") from build() in mode: "mesh" to export an unchanged, prepared reference STL for cad_check_fit. Declare every linked OBJ/MTL/texture asset. If you crop, simplify, fill, or otherwise alter this reference, report exactly what you excluded/changed and that the fit check proves only that reduced reference in the stated pose. A fit check against a scan is information; it must never resize or override an interface specified by measured dimensions. Keep those measured interfaces and report the discrepancy.
|
|
391
391
|
Result selection and edits: set final: true only on the result you select. cad-result.json in each immediate run folder is protected from script writes and retains final, completed_at, lineage_id (source hash), full checks and artifact paths; clients can discover the latest completed final record after restart without rebuilding. Final is a selection marker, not a replacement for valid/checks. Queued calls may expire with cad-queue-timeout before dispatch; do not automatically replay. Unchanged declared files reuse a read-only content-addressed bundle under output_dir/.cad-inputs, preserving filenames and restricting reads to that bundle. Keep this shared cache with the saved runs.
|
|
392
392
|
Mesh cleanup workflow: return a trimesh.Trimesh in mode: "mesh". Load the prepared mesh, fit needed geometry with NumPy/SciPy, rebuild regular sections/features with build123d or manifold3d CrossSection/extrusion/revolve, and combine meshes with manifold3d booleans. scikit-image supplies marching cubes for voxel/SDF work; Shapely supplies planar operations; Pillow supplies image/texture reads. Keep numeric choices in P and regenerate from declared inputs. Validate closure, winding, manifold status, dimensions and all six views using cad_run. What to regularise, infer, preserve or label comes from the caller's cleanup rules, not this engine prompt.
|
|
393
|
-
Multi-colour 3MF projects: build() may return project_3mf() instead of a shape. A new project: p = project_3mf(); p.add_part(shape, name="Lid", filament=2, color="#1A1A1A", object="Box", plate=1) for each part (parts that share object= are one object, printed as one piece; plates from 1; color, given for every part or none, declares each filament's colour in the 3MF), in solid mode with build123d shapes (the checks fuse each object's parts) or mode: "mesh" with trimesh parts. Editing a designer's 3MF: declare it as an input and p = project_3mf("kit") in mode: "mesh"; p.objects lists its objects (name, id, plate; p.object(id or unique name)) and their parts (name, id, filament, painted, mesh: a trimesh in the object's frame); p.add_part(shape, name=..., filament=..., object="Body") adds a part in that object's frame, p.replace_part(part, mesh) swaps a part's mesh (its painting goes with the old mesh) and p.set_part(part, name=..., filament=...) renames or recolours one; everything else in the file (print settings, painting, plates, other parts) is kept. cad_run writes <name>.3mf beside the STL and returns three_mf and three_mf_project (each plate's parts and filaments, read back from the file); slice it with slice_stl, never by rebuilding it from the STL. A design in several colours gets them from the same run as the model: build() returns project_3mf() with one add_part per colour body, so one cad_run builds the shape once and writes the STL and the 3MF together. Never re-run the whole script once per colour to export each colour's STL: that repeats the full build for every colour.
|
|
393
|
+
Multi-colour 3MF projects: build() may return project_3mf() instead of a shape. A new project: p = project_3mf(); p.add_part(shape, name="Lid", filament=2, color="#1A1A1A", object="Box", plate=1) for each part (parts that share object= are one object, printed as one piece; plates from 1; color, given for every part or none, declares each filament's colour in the 3MF), in solid mode with build123d shapes (the checks fuse each object's parts) or mode: "mesh" with trimesh parts. Editing a designer's 3MF: declare it as an input and p = project_3mf("kit") in mode: "mesh"; p.objects lists its objects (name, id, plate; p.object(id or unique name)) and their parts (name, id, filament, painted, mesh: a trimesh in the object's frame); p.add_part(shape, name=..., filament=..., object="Body") adds a part in that object's frame, p.replace_part(part, mesh) swaps a part's mesh (its painting goes with the old mesh) and p.set_part(part, name=..., filament=...) renames or recolours one; everything else in the file (print settings, painting, plates, other parts) is kept. cad_run writes <name>.3mf beside the STL and returns three_mf and three_mf_project (each plate's parts and filaments, read back from the file); slice it with slice_stl, never by rebuilding it from the STL. A design gets several colours only when the printer can feed them (fdm_multicolor: one colour by default on a printer without an AMS, and the summary says why). A design in several colours gets them from the same run as the model: build() returns project_3mf() with one add_part per colour body, so one cad_run builds the shape once and writes the STL and the 3MF together. Never re-run the whole script once per colour to export each colour's STL: that repeats the full build for every colour.
|
|
394
394
|
Captured scan touch-up: t = scan_touchup(load_scan("scan", source_units="m", up_axis="y", ground=False), colour="colour", normal="normal", edge_mm=0.4) takes a textured capture (declare its OBJ, MTL and colour and normal map PNGs as inputs; pass the map aliases). It removes loose pieces and spikes, closes holes and refines to edge_mm without shrinking the body. t.regions() prints the colour regions (id, colour, area, size, flatness; 0 is the body) to build.log and saves regions.png in the run folder: read both, then name regions by id in the same scan and edge_mm. t.flatten(ids, shape="plane" or "curved"), t.bead(id, diameter_mm, proud_mm), t.cord(id, diameter_mm, proud_mm) (a cord follows its region's own curve) and t.seat(height_mm) record steps; return t.mesh(relief_gain=1.0), which adds the normal map's measured relief, applies the steps with manifold3d and prints its changes. Keep relief_gain at 1: a larger gain amplifies the map's noise, not stitches. When the caller's rules call for a textile's relief the scan missed (fabric, knit, crochet the photos show raised), t.texture_relief(height_mm, regions=None) raises its stitch pattern from the colour texture on the textile only (never flattened, beaded or corded regions); about 0.6 to 1.0 mm peak to peak prints visibly. It is off unless called: never for hard objects, printed graphics or labels.
|
|
395
395
|
The result includes paths, millimetre bounds/size, mesh and STEP volumes, solid count, watertight/manifold/winding/STEP checks, bodies (closest approach between solids, contact with the print plate at Z = 0, labelled bodies that are not one solid), problems, checked and not_checked, six orthographic renders (front, back, left, right, top, bottom), a perspective view from the front right and above, and a contact sheet with the perspective view large beside the six. Fix every entry in problems before selecting a result; an empty problems list proves nothing listed in not_checked. After every cad_run, Read its perspective view (renders.perspective, as the result's next says) before the next cad_run or any other change: a run you have not looked at tells you nothing about the form. Judge the form from the perspective view first: would a person recognise the product and want it? Then inspect all six; revise visible defects. Before the final run, list what the views show is wrong against the bought product you named (for a scan, the object in its photos), and fix each one or report it. To get a number out of a design (a spring force, a strain, a clearance you derived), print() it in the script: the result returns it as printed, with no need to make a run fail. A valid mesh or nominal parameter does not prove the requested dimension: measure the actual exported interfaces. Use cad_check_fit on a model and reference STL with an explicit rigid transform; report raw-scan interference and minimum gap. Calipers are authoritative but disagreement with a scan is unresolved measurement evidence, not permission to silently rescale it. Check assembly/insertion paths and actual articulated poses, not sums of local joint limits or reference points alone. Printing, clearance under load, supports and motion need separate evidence.
|
|
396
396
|
Fit, flexure and thread parameters: put each interface's nominal size, its source (measured, published, or assumed), the print correction, and the design fit in P as separate named values, so a fit report revises one number without resending the script. Model every dimension you claim: a parameter the geometry never uses (a wallet or case width that no cut or wall reads) is a defect; use it or remove it. Shape flexures so their bending lies in the layer plane of the exported print orientation, with the stroke, preload, and hard-stop gap as P values; build the stopped pose as well as the rest pose when checking. Model printed threads as explicit coarse geometry with the same pitch on both sides and clearance as a radial P offset; never scale a screw to clear its hole.
|
|
@@ -11,7 +11,7 @@ export interface DesignPrompt {
|
|
|
11
11
|
text: string;
|
|
12
12
|
}
|
|
13
13
|
export declare const FDM_CORE = "Design the finished object the user wants, with the manufacturing plan as part of the design. Preserve its function, fit, and visual identity. Use your design ability freely to make that outcome practical through geometry, orientation, materials, color placement, supports, and assembly.\n\nUse the actual printer and material context: nozzle arrangement and filament routing, build volume, nozzle and line widths, layer profile, cooling, available filaments, and relevant successful prints or calibration. Missing information is unknown, not a capability the printer automatically has. Use reasonable, labeled assumptions for reversible choices; ask only when an unknown materially changes the result.\n\nBefore committing to detailed geometry, choose a plausible way to manufacture and assemble it. For a consequential tradeoff, compare the strongest one-piece approach with a meaningfully different orientation or split. Simple parts do not need a design tournament. Decide it in a few lines and build a rough model of it early: the first geometry is how you check a plan, not the reward for finishing one. Judge total effort to obtain a good finished object: printing, consumed filament, likely rework, support cleanup, assembly, and extra hardware. Respect the user's priorities instead of applying fixed numerical weights.\n\nKeep assembled orientation and print orientation distinct. Preserve critical dimensions and mating surfaces. Account for measurement uncertainty and fit clearance separately; a scan or printed measuring tool does not establish its own accuracy. Use the smallest useful fit sample when uncertainty could otherwise waste a substantial print. A size the person confirmed without changing a prefilled number is not a measurement. If a case, cover, or attachment is mentioned, the bare product's size is not the size to design to.\n\nFind out before you design, and before you ask. Research whenever the request names something that exists outside the person's hands (a product, a vehicle and its year, a phone, a case, a tool, an appliance, a standard part, a material, the place the part mounts) or a decision turns on a fact about the world (how hot it gets there, what the surface is made of, what adhesive holds on it, where the buttons, ports, vents or airbags are). Do not research what exists only with the person: which of their own things, how something felt, what they prefer, an object they measured or scanned. This takes a few minutes, not an hour, and it works the same with any model that has web tools:\n1. Write down the few facts that decide this design, usually three to seven: each interface's size, where the part mounts and what surrounds that spot, what the surface is made of, the environment, the load.\n2. Search each fact by the exact name, model and year or generation plus the fact itself (\"dimensions mm\", \"technical drawing\", \"accessory design guidelines\", \"spec sheet\", \"parts diagram\", \"teardown\", \"material\"). Run the searches together when the tools allow. Makers of fitted accessories for the same object (mounts, cases, installation kits, replacement panels) publish where things go and how big the openings are; owners publish photos with a tape measure; parts catalogues show each panel's outline. Look there, not only at the maker of the object.\n3. Open the page and read the number. A search-result snippet is not a source. Prefer, in order: the maker's drawing or specification, a standard, a fitted-accessory maker, a reviewer's or owner's measurement, a retailer's listing. Two independent sources that agree beat one.\n4. When a first search finds nothing, rephrase before concluding anything: the generation or chassis code, the part number, another market's name for it, the accessory that fits it instead of the thing itself. \"Not found\" is true only after that, and you say where you looked.\n5. Keep each fact with its value, its source and its kind (maker, standard, accessory maker, measurement, listing), labelled as published, and design to it.\n6. For what is still unknown after about two rounds per fact, shape the design so that fact does not decide whether it works (an adjustable or sprung interface, a foot that suits more than one surface), or state a bounded assumption as an assumption. Ask the person only as the last resort, one short question, and only for what exists nowhere but with them. Never ask for something a search answers: a photo of their car's dashboard, the size of a named product, what a named surface is made of.\nWithout web tools, say so in the result, use what you recall labelled as recalled rather than published, and lean harder on step 6.\n\nWrite the concept down in a few lines, with the first build rather than as a plan before it: the bought product you are following, its mechanism, the load path, and how it will print. Before choosing a mechanism, establish what every working bought or published version of the thing has, and keep all of it. For example, a car phone holder turns and tilts to face the driver; a mount's base is sized by the moment of what it holds, not just its weight; an adhesive mount uses a full pad of the tape's grade, not a strip, on a surface the tape suits. Start from the complete product a capable designer would describe at once, then make it printable. A design that leaves out a feature they all have says what it lost and why that is acceptable for this person.\n\nGive it the product's form as well as its function. The bought thing's shape is evidence: a handle swells where the palm closes, a hook's arm thickens towards its root, a knob is round and knurled, a clip's jaws wrap what they hold. Do not reduce a product to a flat profile pushed up, or a box with holes, because that is quick to model and prints without thought: that is a bracket, and people can tell. Put curves where hands and objects touch and where load turns a corner. A flat, in-plane layout is right only for the element that needs it (a spring that must bend in the layer plane, a print-in-place hinge or chain), and then say so; the rest of the product keeps its form, split or turned for printing if need be. When the engine renders the model, look at a three-quarter view and ask whether a person would recognise the thing and want it.\n\nChoose each fit by what that interface has to do: drop in and lift out, slide, locate without rattle, grip so it does not slip or turn, snap over, or press in to stay. There is no single fit number. Keep three things apart for each interface: the object's size and how sure it is, the correction this printer and orientation need (its own observed corrections first, when the context supplies them), and the fit the function calls for. When the size's uncertainty is wider than the function tolerates, do not answer with a better number: choose a mechanism that absorbs the difference (crush ribs, a split closed by a screw, a flexure, a snap), or ask for the one measurement that settles it. The same object changes with time and use: full and nearly empty, new and worn, soft and stiff. A fit that relies on the object giving way must still work in its stiffest, largest state, and a pocket is sized to the widest section the object passes through on the way in, with support where the object actually bears, not to its bounding box.\n\nEvaluate printability locally. Distinguish a progressively supported overhang, a bridge anchored at both ends, and a disconnected island. State overhang angles from vertical: 0 degrees is a vertical wall; 90 degrees is a horizontal underside. Convert conventions before setting slicer angles. Use relevant measured capability ahead of generic rules. A 45-degree threshold is not a universal support requirement, and a steep surface is not automatically unprintable. Judge bridge length along the actual unsupported extrusion path, with its anchors, cooling, material, and required underside quality. A feature that survives printing may still miss a cosmetic or dimensional requirement.\n\nResolve a difficult region with the least disruptive effective change: a better orientation, local geometry, suitable process settings, accessible support, a deliberate breakaway feature, or a split. Supports are an ordinary manufacturing option. Preserve attractive curves and useful complexity when modest support or cleanup achieves them. Check support removal and tool access, especially inside cavities. Avoid changing the whole object to solve a local problem.\n\nChoose layer orientation, material, walls, and joints for the actual loads and environment. Check the load path, flexing features, fastener access, and installation sequence. Judge a connection (tape, screws, a snap) against products that demonstrably work. If a check says a bought product that holds for years would fail, the check is wrong: correct it, then apply it to your design. A reduction in supports or color changes must not silently weaken the part or defeat its fit.\n\nWhen a part must flex, grip, snap, clip, spring, or hold something, consider a compliant mechanism first: one piece that bends on purpose often beats rigid jaws plus a clamp bolt, with fewer parts, no fastener to buy or lose, and a hold that follows the object. That choice is for the element that grips, clips or springs, not for the product: it is never a reason to make the whole thing one piece or to drop a joint, adjustment or base the bought versions have. Spread the bending over a long band, leaf, or arch rather than a short stub; keep the rest of the body stiff so the stroke goes where you intend; give a hand enough leverage; design the preload in; use an over-centre or cam where a hold must lock; and give every flexing direction a hard stop so a hard pull meets solid material. Keep the bending in the layer plane, where the filament runs along the strain; bending that pulls layers apart is far weaker and fails with little warning. Choose the strain by duty (bent once to assemble, bent every day, and held bent for months are different designs) and by material and direction, using the printer's own observed values when the context supplies them. Modern PLA and PETG grades are not brittle in this role: proven printed springs work daily at strains that older moulded-plastic tables would forbid. What usually ends a flexure is not a clean snap at a magic percentage but whitening and set at a sharp root, layers parting where the bend crosses them, or a held bend creeping loose, faster when warm. In sustained heat such as a parked car, a part held bent relaxes and a sun-heated dashboard can exceed what PLA or PETG carry under load: prefer a rest state that sits unstrained, and say so when the material cannot honestly do the job. A part a hand works has to be easy to work, and that is checked like its hold: say where the fingers go, how hard they push to open it, how far it opens, and how the object goes in and comes out with one hand. A grip that meets its force and is a fight to use has failed the brief.\n\nOn a shared-nozzle multicolor setup, reason about filament transitions across layers, including support-interface material. Total color count alone is a poor cost estimate. Consider color placement, shallow inlays, separately printed accents, and part orientation while preserving the requested appearance. Separate bodies on one layer-printed plate can still cause repeated swaps. Use the slicer's actual schedule and estimates when available; do not invent a fixed cost per color change.\n\nUse assembly when its benefit is worth the user's additional work. Design alignment, clearance, engagement, and assembly access deliberately. Glue is a valid planned joining method for suitable materials and loads; make joints self-locating and give them useful bonding area. Use mechanical retention when loads, repeated flexing, or serviceability call for it. State needed glue, hardware, tools, and assembly effort plainly. Avoid adding parts when a modest support or a simple one-piece print is the better result. A printed screw, nut, or threaded hole is an ordinary choice at hand sizes (M8 and up as the usual starting point, about M6 as the floor) with a coarse profile shaped to print without supports; below that floor, under sustained preload that must not relax, in heat, or under shock, a metal screw or insert is the honest choice. Keep threads out of the main load path where a shoulder, tenon, key, or serrated face can carry shear and torque, and let the thread only hold the joint closed.\n\nVerify the chosen geometry in its actual print orientation and inspect the slice when tools permit. Check critical fits, missing or floating features, toolpaths, supports, color assignments, total time, and material consumption. Treat a slicer prediction as a prediction, not a physical test. Fix consequential problems and re-slice relevant changes. A cosmetic slicer warning (floating regions, small islands) gets one targeted fix and one re-slice, then stops: report what remains, or slice with supports on. Stop when the design meets the brief and no remaining improvement justifies its cost. State \"prints without supports\", \"holds\", or \"fits\" only when the engine's own checks or the slice show it, and give the number that shows it; otherwise call it an untested prediction.\n\nFit and flexure guidance is longer than this text and is read when it applies: fdm_fit whenever a part meets a real object or another part, fdm_flexures whenever a part must flex, grip, snap, clip or spring. If your host did not attach them, read them with this MCP's design_guidance tool before you choose that fit or size that spring. Where the MCP's code engine is in use, its cad_examples tool lists worked designs to start from.\n\nKeep the user-facing result short: the recommended design, why its manufacturing approach makes sense, how it prints and assembles, and any consequential unresolved assumption. Distinguish measured dimensions, slicer estimates, and untested predictions. Say where each critical size came from (measured, published, or assumed) and what each interface is meant to do and how it fits. Keep detailed analysis in the working process.";
|
|
14
|
-
export declare const FDM_MULTICOLOR = "Apply this guidance when multiple colors or support materials share a print.\n\nPreserve the requested visual pattern. Evaluate its colors in build coordinates and across layers before committing to color geometry. On a shared nozzle, a small accent spanning many layers can create more transitions than a large region confined to a few layers. Count the slicer's actual transitions when available, including swaps back to a prior filament and support-interface swaps; color count and colored volume are only screening clues. On printers with multiple nozzles, evaluate each shared melt path; AMS slots are not independent nozzles.\n\nFor a costly pattern, consider the most promising alternatives: a different build orientation, color regions confined to fewer layers, shallow face inlays, or separately printed single-color pieces with intentional assembly. A vertical stripe in use may become a low-change feature in a different print orientation. Judge each option against load direction, surface quality, support burden, and the user's exact visual requirements. Finer layers can help an overhang while adding color-change layers; evaluate local adaptive layers and re-slice the combined plan.\n\nWhen this MCP's code engine makes the model, its colour parts come from the same cad_run as the model (build() returns project_3mf(), one part per colour), never from re-running the whole script once per colour.\n\nSeparating color bodies does not by itself eliminate swaps. Check plate scheduling. Single-color plates can remove repeated color changes; by-layer printing of different-color objects together usually cannot. Use sequential object printing only when supported and its clearance constraints are satisfied. Batch copies only when the user wants them.\n\nUse the actual directional flushing matrix and filament compatibility. Purging clears previous material; priming restores consistent extrusion. Track those separately when the slicer does. Flushing into compatible infill or supports may reduce discarded material, but it does not remove switching time, has finite capacity, and can affect appearance or strength. Do not add unnecessary infill or objects merely to hide waste.\n\nCompare the same requested quantity and finish. Report total filament and time across all plates, plus purge, tower, and support quantities only where available without double counting. Unknown metrics remain unknown. Recommend the original multicolor approach when the user values its seamless result enough to justify its cost.";
|
|
14
|
+
export declare const FDM_MULTICOLOR = "Apply this guidance when multiple colors or support materials share a print.\n\nFirst check that the printer can feed the colours itself. get_printer_filaments lists its AMS trays: a connected printer with none has no AMS and feeds one filament at a time, or one per nozzle on a dual-nozzle printer. When it can't feed them (no AMS or other multi-material unit, or fewer filaments than colours), make the design in one colour by default, even a copy of an object the photos show in several, because every colour change would stop the print for a manual swap. Say why in the summary in plain words, for example: \"Your printer has no AMS, so it's one colour; ask for two colours if you'll change filament by hand.\" Make it in colours only when the person asks for them; then slice with manual_filament_changes: true and say how many times it stops (filament_changes in the slice result). When you can't tell whether the printer has an AMS, keep the colours and say that without an AMS it stops at each colour change. slice_stl refuses a slice in more colours than the printer is known to feed (needs-more-filaments) and flags one it can't check.\n\nPreserve the requested visual pattern. Evaluate its colors in build coordinates and across layers before committing to color geometry. On a shared nozzle, a small accent spanning many layers can create more transitions than a large region confined to a few layers. Count the slicer's actual transitions when available, including swaps back to a prior filament and support-interface swaps; color count and colored volume are only screening clues. On printers with multiple nozzles, evaluate each shared melt path; AMS slots are not independent nozzles.\n\nFor a costly pattern, consider the most promising alternatives: a different build orientation, color regions confined to fewer layers, shallow face inlays, or separately printed single-color pieces with intentional assembly. A vertical stripe in use may become a low-change feature in a different print orientation. Judge each option against load direction, surface quality, support burden, and the user's exact visual requirements. Finer layers can help an overhang while adding color-change layers; evaluate local adaptive layers and re-slice the combined plan.\n\nWhen this MCP's code engine makes the model, its colour parts come from the same cad_run as the model (build() returns project_3mf(), one part per colour), never from re-running the whole script once per colour.\n\nSeparating color bodies does not by itself eliminate swaps. Check plate scheduling. Single-color plates can remove repeated color changes; by-layer printing of different-color objects together usually cannot. Use sequential object printing only when supported and its clearance constraints are satisfied. Batch copies only when the user wants them.\n\nUse the actual directional flushing matrix and filament compatibility. Purging clears previous material; priming restores consistent extrusion. Track those separately when the slicer does. Flushing into compatible infill or supports may reduce discarded material, but it does not remove switching time, has finite capacity, and can affect appearance or strength. Do not add unnecessary infill or objects merely to hide waste.\n\nCompare the same requested quantity and finish. Report total filament and time across all plates, plus purge, tower, and support quantities only where available without double counting. Unknown metrics remain unknown. Recommend the original multicolor approach when the user values its seamless result enough to justify its cost.";
|
|
15
15
|
export declare const FDM_ASSEMBLY = "Apply this guidance when a split, insert, or joint may materially improve the result.\n\nCompare assembly against the best practical one-piece approach, including reasonable supports. A split earns its place by improving important surfaces, layer strength, fit, color efficiency, support access, repairability, or bed fit enough to justify handling and joining the pieces. Prefer a one-piece solution when its support cleanup is easier than assembly and the alternatives meet the other important requirements comparably well. Respect an explicit one-piece or no-glue requirement.\n\nPut boundaries where they are structurally sensible and visually deliberate. Use shoulders, keys, overlapping faces, tabs, or pins to locate parts and resist sliding or rotation as appropriate. Include fit clearance, lead-ins, adhesive space where needed, and a feasible insertion path. Check the assembled geometry and the order of operations, not only the separated pieces. Avoid joints whose screws, clamps, or mating faces become inaccessible during assembly.\n\nFor suitable lightly loaded rigid details, a locating pocket plus a compatible adhesive can be the simplest reliable solution. For a loaded clamp, a joint under peel or repeated bending, or a serviceable assembly, consider fasteners or mechanically captured geometry. Do not assume a tiny glued butt joint can carry the same load as an intact printed section. Select adhesive from evidence for the actual materials and conditions; superglue is an option, not a universal material property.\n\nState the practical consequence directly: which parts print in which orientations and colors, how they locate, how they are retained, which supplies are needed, and the estimated hands-on work. Keep hands-on time separate from adhesive cure time. Check a small joint sample only when its uncertain fit or strength would change the design decision.\n\nPrinted threads need a profile made for printing, not a copy of a metal V-thread. A coarse, truncated thread whose flanks sit within the printer's proven overhang (one widely printed all-plastic kit uses about a 96-degree included angle, 42 degrees from vertical, at pitches of roughly 2-3 mm for M8-M12 sizes, cleared by roughly two tenths of a millimetre per side at the pitch line) prints upright without supports and keeps its teeth in solid wall loops. Keep the pitch exactly the same on screw and hole; make clearance by shifting the profile radially, never by scaling the screw, which changes the pitch and wedges after a few turns. Give a hand screw several full turns of engagement and a knob that limits how hard it can be torqued. A long, slender screw that must pull or bend is better printed flat or split so filament runs along its length than stood upright across its layers. Where preload must survive months, heat, or shock, or the size is below about M6-M8, use a metal screw or heat-set insert and say so. When the context supplies this printer's own thread fit observation, use it ahead of any generic allowance.";
|
|
16
16
|
export declare const FDM_AFTER_SLICE = "Review this slice against the user's brief and the selected manufacturing plan. Use the returned slice, geometry, profile, and calibration evidence; do not assume missing metrics are zero.\n\nCheck that the actual toolpaths preserve critical features, fit, connected material, intended colors, and load-bearing sections. Inspect consequential first layers, bridges, islands, supported undersides, and removal access. Compare expected total print time, total material across all plates, and manual work with the best credible alternative. Keep purge, prime-tower, support, and model quantities distinct only when the data provides a non-overlapping breakdown.\n\nIf the plan is unexpectedly costly or fragile, identify the dominant cause and make the smallest change that preserves the brief. Re-slice after a relevant geometry, orientation, material, or process change. A cosmetic warning (floating regions, small islands) gets one targeted fix and one re-slice, then stops: report what remains, or slice with supports on; never loop rebuild and re-slice to chase it. Do not optimize a minor imperfection at the expense of function or appearance, and do not invent a redesign simply to produce criticism. Check every support, fit, and hold claim in the summary against a number from the slice or the engine's checks (support area and worst overhang, engagement and gap, estimated bite at the forced opening). A claim without its number comes out or is labelled a prediction.\n\nReturn a concise decision: keep, revise, or validate one specific uncertainty. Include the decisive evidence and the exact next action. A clean slice supports a printability prediction; it does not verify physical fit, strength, or bridge quality.";
|
|
17
17
|
export declare const FDM_FLEXURES = "Apply this guidance when a part must flex, grip, snap, clip, spring, or hold something by bending. The strain bands below are planning bands drawn from manufacturer printed-specimen cards, measurements of published mechanisms that survive daily use, and single-printer coupon readings. They are not guarantees and not rejection thresholds. When the context supplies this printer's own observed values for the same filament, profile and duty, design to those and keep the generic band as the starting point for everything else.\n\nA compliant design earns its place when one bending piece replaces rigid jaws, a hinge and a clamp bolt: fewer parts, nothing to buy or lose, one print, and a hold that follows the object as it varies. Prefer it for holders, clips, snaps, lids and latches a hand operates, as the element that grips or latches, never in place of a joint, adjustment or base the bought versions have. Do not force it where the job is precise location under a heavy sustained load, a preload that must not relax for months in heat, or travel and force together beyond what a spring can give. There, let solid geometry carry the load (a pin, saddle, rail, shoulder or latch) and let a spring only preload, return, or take up slack.\n\nChoose the architecture before the dimensions. A long leaf, band or arch spreads strain over its length; a short stub concentrates it at the root and either cracks or barely moves. A pair of leaves guided at both ends moves its jaw straight, without tilting. Folding the spring back on itself (a serpentine or S) buys travel in a small space at the same strain. A thick curved arch gives a strong bite over a short opening. An over-centre toggle or cam locks past its peak so the locked strain is lower than the click that got there, and both rest states can sit nearly unstrained. A shallow pre-curved beam latched flat seals along its length while held at a fraction of a percent. A cam lever earns a hard bite by putting its small lift into a short, stiff spring, not by bending long jaws. In every case keep the surrounding body much stiffer than the spring, size the leverage to the hand that works it, design the preload in rather than hoping assembly provides it, and put a solid hard stop just past the working stroke so an oversize object or a hard yank meets compression instead of ever-rising strain.\n\nJudge bite at the opening the object actually forces, where the force is taken. The same clip is several times stiffer when a flat rigid object holds its jaws from turning than when a round finger lets them turn; one measured clip changed about fivefold between those contacts. Grip that must not slip is force times friction; feel and marking are pressure. A narrow ridge concentrates a modest force into a high pressure that seals, grips and, on skin, hurts; a broad flat jaw needs roughly an order of magnitude more force for the same pressure. State the opening, the contact you assumed, and the friction you used. Published dry static friction for printed PLA on itself spans roughly 0.12-0.38 (one printer read 0.25-0.31 on both faces) and PETG on itself roughly 0.13-0.21: use the low end when checking that a hold retains, the high end when checking that a hand can still insert it. Friction against the held object (a phone case, glass, paint) is unknown unless the context gives it; do not substitute the self-contact range for it.\n\nKeep the bending in the layer plane. Filament laid along the strained length carries the bend; a bend that pulls layers apart works at a fraction of that strength (across-layer tensile strength is roughly half to nine-tenths of in-plane depending on grade and test) and parts with little warning. Turn the part, split it, or reshape the spring so its length lies in the layers. If a bend across layers is truly unavoidable, keep its strain well below the in-plane bands, give it generous roots, and bring its hard stop close. Make the spring from continuous wall loops: choose its thickness as whole extrusion widths and enough walls that no sparse infill sits inside the neck. Taper toward the tip where travel allows, fillet every root or curve continuously through it, and never hang a spring from a sharp internal corner.\n\nChoose strain by duty first, then material. In the layer plane, as planning bands: held bent for months at room temperature, keep PLA to about 0.5% or less and PETG to about 1.4% or less, and prefer a shape whose rest state is unstrained so holding costs nothing; bent every day for hundreds to thousands of cycles, proven mechanisms commonly work at about 1.5-2.6% in PLA and about 2-3.4% in PETG; bent once to assemble, or touched only at the hard stop, PLA on one coupon-tested printer survived 3.3% once and ten times in both orientations without cracking, and proven PETG designs peak at about 4-4.3%. Treat those peaks as no-crack evidence, not proof of full spring-back: past roughly 3.3-3.4% PLA begins to whiten and take set in published printed-specimen testing, long before its published break elongation (about 12% in-plane for one current PLA grade), because break includes permanent deformation a spring cannot use. Older moulded-plastic snap allowances near 1-1.7% are not printed fracture limits; designing every spring to them produces weak, timid parts. Grade matters as much as polymer family: current cards put one PETG grade's tensile modulus near 2780 MPa and another's near 1810 MPa, so size force from the actual grade's card or an observed deflection (one printer's PLA measured about 2600 MPa, close to its 2580 MPa card), never from the family name alone.\n\nExpect, in order: a sharp root whitens, yields and takes set; a bend across layers delaminates; a held bend creeps and its force fades; only then does a well-shaped in-plane spring crack. Design so the first failure you would meet is harmless and visible, and so the hard stop prevents the rest.\n\nHeat changes the answer before it melts anything. PLA grades soften under load from roughly the mid-50s C (heat deflection about 54-57 C, glass transition about 60 C) and PETG grades from roughly the low 60s to about 70 C depending on grade and load (glass transition about 66-69 C); published creep tests already move faster after brief warming near 46 C. A sun-parked dashboard has been documented around 70 C within an hour. Judge by exposure and load together: a shaded, unloaded trim piece is not a loaded spring on a dashboard. For sun-exposed parts that must stay bent or carry load, neither PLA nor PETG is an honest default; prefer a higher-temperature filament the printer actually has, a rest state at zero strain while parked empty, and positive capture (lips, shelves, a latch) so friction alone never decides whether the object stays. Say plainly when the loaded filaments cannot do the thermal job instead of silently printing it anyway.\n\nIn the result, give the duty you designed for, how a hand operates it (where the fingers go and the force to open it at the tabs), the working and hard-stop strains and how you estimated them, the bite or spring force at the stated opening with its contact and friction assumptions, the rest strain, and the heat verdict. A force without its opening, or a strain without its duty, is not yet a claim.";
|
package/dist/design-guidance.js
CHANGED
|
@@ -42,6 +42,8 @@ Fit and flexure guidance is longer than this text and is read when it applies: f
|
|
|
42
42
|
Keep the user-facing result short: the recommended design, why its manufacturing approach makes sense, how it prints and assembles, and any consequential unresolved assumption. Distinguish measured dimensions, slicer estimates, and untested predictions. Say where each critical size came from (measured, published, or assumed) and what each interface is meant to do and how it fits. Keep detailed analysis in the working process.`;
|
|
43
43
|
export const FDM_MULTICOLOR = `Apply this guidance when multiple colors or support materials share a print.
|
|
44
44
|
|
|
45
|
+
First check that the printer can feed the colours itself. get_printer_filaments lists its AMS trays: a connected printer with none has no AMS and feeds one filament at a time, or one per nozzle on a dual-nozzle printer. When it can't feed them (no AMS or other multi-material unit, or fewer filaments than colours), make the design in one colour by default, even a copy of an object the photos show in several, because every colour change would stop the print for a manual swap. Say why in the summary in plain words, for example: "Your printer has no AMS, so it's one colour; ask for two colours if you'll change filament by hand." Make it in colours only when the person asks for them; then slice with manual_filament_changes: true and say how many times it stops (filament_changes in the slice result). When you can't tell whether the printer has an AMS, keep the colours and say that without an AMS it stops at each colour change. slice_stl refuses a slice in more colours than the printer is known to feed (needs-more-filaments) and flags one it can't check.
|
|
46
|
+
|
|
45
47
|
Preserve the requested visual pattern. Evaluate its colors in build coordinates and across layers before committing to color geometry. On a shared nozzle, a small accent spanning many layers can create more transitions than a large region confined to a few layers. Count the slicer's actual transitions when available, including swaps back to a prior filament and support-interface swaps; color count and colored volume are only screening clues. On printers with multiple nozzles, evaluate each shared melt path; AMS slots are not independent nozzles.
|
|
46
48
|
|
|
47
49
|
For a costly pattern, consider the most promising alternatives: a different build orientation, color regions confined to fewer layers, shallow face inlays, or separately printed single-color pieces with intentional assembly. A vertical stripe in use may become a low-change feature in a different print orientation. Judge each option against load direction, surface quality, support burden, and the user's exact visual requirements. Finer layers can help an overhang while adding color-change layers; evaluate local adaptive layers and re-slice the combined plan.
|
|
@@ -384,6 +386,7 @@ export function slicingGuidance(slicerType, capabilities) {
|
|
|
384
386
|
capabilities.orient
|
|
385
387
|
? `- Orientation: slice_stl with orient true lets ${slicer}'s own auto-orient choose how an STL sits on the bed. It keeps overhang area low; it does not check cantilevers. To see what it chooses, slice the checkpoint with orient true. When a print is oriented this way, don't promise a particular orientation on the bed: the slicer chooses it.`
|
|
386
388
|
: `- Orientation: ${slicer} doesn't auto-orient here. An STL prints in the orientation it's exported in.`,
|
|
389
|
+
"- Colours: a slice in more colours than the printer can feed (no AMS, or fewer filaments than colours) is refused with needs-more-filaments, its filament_changes and a plain message; when the printer can't be asked it succeeds with filament_feed and a note. One colour is the default on such a printer (fdm_multicolor); slice with manual_filament_changes: true only when the person will change filament by hand.",
|
|
387
390
|
capabilities.supports
|
|
388
391
|
? "- Supports: set enable_support on every slice_stl call. With enable_support true it generates supports in the style support_type names (tree(auto) or normal(auto)); with false it generates none; left out, the process preset's own setting applies. Slice the checkpoint with enable_support set the way the print will be sliced. A print gets the supports it was sliced with: print the sliced file itself, or slice the print with slice_stl and the same enable_support and support_type. print_3mf's own slicing of a file that isn't sliced yet takes no support settings; it uses the process profile's."
|
|
389
392
|
: `- Supports: ${slicer} takes no support settings from slice_stl here: whether it generates supports is its configured profile's own setting. Slice a checkpoint to see what that profile does before modeling any support yourself.`,
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { withRemote } from "./counterpart/remote.js";
|
|
|
8
8
|
import { refusalReport, slicedFileFacts, slicerReport } from "./counterpart/sliced-file.js";
|
|
9
9
|
import { listModelPlates } from "./counterpart/model-plates.js";
|
|
10
10
|
import { floatingWarningFacts } from "./slicer/floating-regions.js";
|
|
11
|
+
import { feedFromBambuReport, feedVerdict, sliceColours, UNKNOWN_FEED } from "./slicer/filament-feed.js";
|
|
11
12
|
/** The slicer's verdict beside its result.json (`slicer_report`). */
|
|
12
13
|
function reportOf(result) {
|
|
13
14
|
const report = slicerReport(result);
|
|
@@ -1730,6 +1731,33 @@ class BambuPrinterMCPServer {
|
|
|
1730
1731
|
}, onUpdate, { signal, assertActive });
|
|
1731
1732
|
});
|
|
1732
1733
|
}
|
|
1734
|
+
/**
|
|
1735
|
+
* The filaments the configured printer can feed itself, for a multi-colour slice (src/slicer/filament-feed.ts):
|
|
1736
|
+
* its AMS trays and external spools from a fresh report, or unknown without one. Only reads status.
|
|
1737
|
+
*/
|
|
1738
|
+
async printerFeed(usePrinterFilaments, model, host, bambuSerial, bambuToken) {
|
|
1739
|
+
const dual = isDualNozzleModel(model);
|
|
1740
|
+
const unknown = (source) => UNKNOWN_FEED(source, dual);
|
|
1741
|
+
if (!usePrinterFilaments)
|
|
1742
|
+
return unknown("use_printer_filaments is false, so the printer wasn't asked");
|
|
1743
|
+
if (!bambuSerial || !bambuToken)
|
|
1744
|
+
return unknown("no printer is configured to ask");
|
|
1745
|
+
try {
|
|
1746
|
+
let status = await this.bambu.getStatus(host, bambuSerial, bambuToken);
|
|
1747
|
+
let feed = feedFromBambuReport(status?.raw, status?.connected === true, dual);
|
|
1748
|
+
// An idle printer's first push can be sparse; its AMS block follows (as get_printer_filaments waits for). A
|
|
1749
|
+
// printer that isn't connected isn't asked twice.
|
|
1750
|
+
if (status?.connected === true && (!feed.known || feed.ams_slots === 0)) {
|
|
1751
|
+
await new Promise(resolve => setTimeout(resolve, 1500));
|
|
1752
|
+
status = await this.bambu.getStatus(host, bambuSerial, bambuToken);
|
|
1753
|
+
feed = feedFromBambuReport(status?.raw, status?.connected === true, dual);
|
|
1754
|
+
}
|
|
1755
|
+
return feed;
|
|
1756
|
+
}
|
|
1757
|
+
catch {
|
|
1758
|
+
return unknown("the printer could not be reached");
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1733
1761
|
async getResolvedPrinterFilamentInventory(host, bambuSerial, bambuToken, bambuModel, nozzleDiameter) {
|
|
1734
1762
|
const status = await this.bambu.getStatus(host, bambuSerial, bambuToken);
|
|
1735
1763
|
let inventory = normalizePrinterFilamentInventory(status, bambuModel, nozzleDiameter);
|
|
@@ -2301,11 +2329,12 @@ class BambuPrinterMCPServer {
|
|
|
2301
2329
|
},
|
|
2302
2330
|
{
|
|
2303
2331
|
name: "slice_stl",
|
|
2304
|
-
description: "Slice an STL or 3MF file using a slicer to generate printable G-code or sliced 3MF. IMPORTANT: bambu_model must be specified to ensure the slicer generates safe G-code for the correct printer. The text result is the sliced file's path. When Bambu Studio or OrcaSlicer writes a result.json, structuredContent.slicer_result carries it verbatim, success or error: error_string, return_code and each sliced_plates[].warning_message, such as a floating cantilever. structuredContent.slicer_report says whether it failed; for a failure, its message is a plain sentence for a person and slicer_message keeps the slicer's words, which a failed slice's text gives after that sentence. When a slice that worked warns of floating regions, next carries the stop rule (one targeted fix and one re-slice, then report it or slice with supports on) and, for an STL the slicer did not turn, structuredContent.floating_regions lists where they are: x and y in the STL's own millimetres, z above its lowest point, and depth_mm, how far each hangs below where it joins the rest. A 3MF that carries its own process settings (a designer's Bambu Studio or Orca project) slices with them unless slicer_profile, template_name or template_3mf_path is given; the machine still comes from bambu_model. quality and strength adjust that process, and strength never lowers its walls or infill.",
|
|
2332
|
+
description: "Slice an STL or 3MF file using a slicer to generate printable G-code or sliced 3MF. IMPORTANT: bambu_model must be specified to ensure the slicer generates safe G-code for the correct printer. The text result is the sliced file's path. When Bambu Studio or OrcaSlicer writes a result.json, structuredContent.slicer_result carries it verbatim, success or error: error_string, return_code and each sliced_plates[].warning_message, such as a floating cantilever. structuredContent.slicer_report says whether it failed; for a failure, its message is a plain sentence for a person and slicer_message keeps the slicer's words, which a failed slice's text gives after that sentence. When a slice that worked warns of floating regions, next carries the stop rule (one targeted fix and one re-slice, then report it or slice with supports on) and, for an STL the slicer did not turn, structuredContent.floating_regions lists where they are: x and y in the STL's own millimetres, z above its lowest point, and depth_mm, how far each hangs below where it joins the rest. A slice in two or more colours carries filament_feed: the colours, the filament changes the slicer reports, and whether the printer can feed them (its AMS trays and external spools from a fresh status read; unknown without one). When the printer is known not to (no AMS, or fewer filaments than colours), slice_stl refuses with code needs-more-filaments, filament_slots, filament_changes and a plain slicer_report.message, unless manual_filament_changes is true; when it is unknown, the slice succeeds and slicer_report.message says how many times it would stop without an AMS. A 3MF that carries its own process settings (a designer's Bambu Studio or Orca project) slices with them unless slicer_profile, template_name or template_3mf_path is given; the machine still comes from bambu_model. quality and strength adjust that process, and strength never lowers its walls or infill.",
|
|
2305
2333
|
inputSchema: {
|
|
2306
2334
|
type: "object",
|
|
2307
2335
|
properties: {
|
|
2308
2336
|
stl_path: { type: "string", description: "Path to the STL or 3MF file to slice" },
|
|
2337
|
+
manual_filament_changes: { type: "boolean", description: "The person will change filament by hand: a slice in more colours than the printer can feed (no AMS) is returned, with the number of changes, instead of refused with needs-more-filaments." },
|
|
2309
2338
|
bambu_model: {
|
|
2310
2339
|
type: "string",
|
|
2311
2340
|
enum: [...VALID_BAMBU_MODELS],
|
|
@@ -4121,7 +4150,19 @@ class BambuPrinterMCPServer {
|
|
|
4121
4150
|
const turned = Boolean(args?.orient) || [args?.rotate, args?.rotate_x, args?.rotate_y].some(r => r !== undefined && Number(r) !== 0)
|
|
4122
4151
|
|| (args?.scale !== undefined && Number(args.scale) !== 1);
|
|
4123
4152
|
const located = await floatingWarningFacts(reported.slicer_report, String(args.stl_path), turned);
|
|
4124
|
-
|
|
4153
|
+
// A slice in several colours on a printer that can't feed them is refused or flagged, never sent on
|
|
4154
|
+
// silently (beta 8 DAD replay: 85 manual changes on a P1S with no AMS). See src/slicer/filament-feed.ts.
|
|
4155
|
+
let feedFacts = {};
|
|
4156
|
+
if (sliceColours(sliced.slicer_result).colours >= 2) {
|
|
4157
|
+
const verdict = feedVerdict(sliced.slicer_result, await this.printerFeed(usePrinterFilaments, sliceModel, host, bambuSerial, bambuToken), args?.manual_filament_changes === true);
|
|
4158
|
+
if (verdict.refusal)
|
|
4159
|
+
throw Object.assign(verdict.refusal, { slicerResult: sliced.slicer_result });
|
|
4160
|
+
if (verdict.facts)
|
|
4161
|
+
feedFacts = { filament_feed: verdict.facts };
|
|
4162
|
+
if (verdict.note && reported.slicer_report)
|
|
4163
|
+
reported.slicer_report = { ...reported.slicer_report, message: reported.slicer_report.message ? `${reported.slicer_report.message}\n${verdict.note}` : verdict.note };
|
|
4164
|
+
}
|
|
4165
|
+
return { content: [{ type: "text", text: sliced.path }], structuredContent: { ...reported, ...located, ...feedFacts } };
|
|
4125
4166
|
}
|
|
4126
4167
|
case "print_3mf": {
|
|
4127
4168
|
if (!args?.three_mf_path) {
|
|
@@ -4579,7 +4620,11 @@ class BambuPrinterMCPServer {
|
|
|
4579
4620
|
// A design in more colours than filaments to slice it with: the counts and the plain answer a client shows.
|
|
4580
4621
|
...(error instanceof FilamentSlotsError ? {
|
|
4581
4622
|
filament_slots: { colours: error.colours, slots: error.slots },
|
|
4582
|
-
|
|
4623
|
+
...(error.changes !== undefined ? { filament_changes: error.changes } : {}),
|
|
4624
|
+
...(error.feed ? { filament_feed: error.feed } : {}),
|
|
4625
|
+
...(error.slicerResult ? { slicer_result: error.slicerResult } : {}),
|
|
4626
|
+
...(error.feed ? { suggestion: "Make it in one colour, or print each colour as its own part. If the person will change filament by hand, slice again with manual_filament_changes: true." } : {}),
|
|
4627
|
+
slicer_report: { failed: true, message: error.plain, slicer_message: error.detail },
|
|
4583
4628
|
} : {}),
|
|
4584
4629
|
};
|
|
4585
4630
|
// MCP clients validate structuredContent against a declared outputSchema even on
|
package/dist/refusal.d.ts
CHANGED
|
@@ -39,5 +39,21 @@ export declare class FilamentSlotsError extends PrinterRefusal {
|
|
|
39
39
|
readonly colours: number;
|
|
40
40
|
readonly slots: number;
|
|
41
41
|
readonly plain: string;
|
|
42
|
-
|
|
42
|
+
/** The filament changes the slice would make, when the slicer reported them (a printer with too few feeds). */
|
|
43
|
+
readonly changes?: number;
|
|
44
|
+
/** The slicer's own words, or this server's when the printer's feeds decided it. */
|
|
45
|
+
readonly detail: string;
|
|
46
|
+
/** The printer's feeds and the slice's colours, when they decided it (slice_stl's filament_feed). */
|
|
47
|
+
feed?: Record<string, unknown>;
|
|
48
|
+
/** The slicer's own result.json for the slice the printer's feeds refused. */
|
|
49
|
+
slicerResult?: unknown;
|
|
50
|
+
/**
|
|
51
|
+
* colours: the colours the design prints with; slots: the filaments there are to feed them (slice slots, or the
|
|
52
|
+
* printer's AMS trays plus external spools). `options` carries the plain sentence when the printer's feeds decide
|
|
53
|
+
* it, and the filament changes the slice would make.
|
|
54
|
+
*/
|
|
55
|
+
constructor(colours: number, slots: number, options?: {
|
|
56
|
+
plain?: string;
|
|
57
|
+
changes?: number;
|
|
58
|
+
});
|
|
43
59
|
}
|
package/dist/refusal.js
CHANGED
|
@@ -51,12 +51,23 @@ export function printOutcome(error) {
|
|
|
51
51
|
* 1 filament slots".
|
|
52
52
|
*/
|
|
53
53
|
export class FilamentSlotsError extends PrinterRefusal {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
/**
|
|
55
|
+
* colours: the colours the design prints with; slots: the filaments there are to feed them (slice slots, or the
|
|
56
|
+
* printer's AMS trays plus external spools). `options` carries the plain sentence when the printer's feeds decide
|
|
57
|
+
* it, and the filament changes the slice would make.
|
|
58
|
+
*/
|
|
59
|
+
constructor(colours, slots, options = {}) {
|
|
60
|
+
const plain = options.plain ?? `This design is in ${colours} colours, but only ${slots} filament${slots === 1 ? " is" : "s are"} available to print it. It needs a printer with an AMS loaded with ${colours} colours, or it can print in one colour.`;
|
|
61
|
+
const detail = options.plain
|
|
62
|
+
? `The design prints in ${colours} filaments and the printer can feed ${slots}${options.changes !== undefined ? `; the slice makes ${options.changes} filament changes` : ""}.`
|
|
63
|
+
: `${colours} filament colours were supplied for ${slots} filament slots.`;
|
|
64
|
+
super("needs-more-filaments", `${plain}\n${options.plain ? "The slice said" : "The slicer setup said"}: ${detail}`);
|
|
57
65
|
this.colours = colours;
|
|
58
66
|
this.slots = slots;
|
|
59
67
|
this.name = "FilamentSlotsError";
|
|
60
68
|
this.plain = plain;
|
|
69
|
+
this.detail = detail;
|
|
70
|
+
if (options.changes !== undefined)
|
|
71
|
+
this.changes = options.changes;
|
|
61
72
|
}
|
|
62
73
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the printer can feed a multi-colour slice itself (beta 8 DAD replay, Nov 17): a two-colour 3MF sliced for a
|
|
3
|
+
* P1S with no AMS succeeded with 85 filament changes and no word, so a tester would have been sent a print that stops
|
|
4
|
+
* 85 times for a manual swap. Shared by bambu-printer-mcp and mcp-3D-printer-server.
|
|
5
|
+
*
|
|
6
|
+
* How the printer's feeds are known (the judgement, written down):
|
|
7
|
+
* - Feeds are the AMS trays the printer reports (every tray of every AMS unit, loaded or not: a person can load an
|
|
8
|
+
* empty one). Without an AMS, its external spool holders, one per nozzle (two on a dual-nozzle model). A print
|
|
9
|
+
* doesn't mix the external spool with AMS trays, so the two are not added. Two external spools feed two colours
|
|
10
|
+
* only when each colour is on its own nozzle; the slice's nozzle bindings aren't read here, so a dual-nozzle
|
|
11
|
+
* printer without an AMS is unknown for two colours (flagged, not passed) and too few for three.
|
|
12
|
+
* - Known only from a connected printer's report that carries its AMS block; one that lists no AMS unit in it means
|
|
13
|
+
* no AMS. A report without the block says nothing. The model alone never decides it: every model's AMS is
|
|
14
|
+
* optional.
|
|
15
|
+
* - Counted per plate: a project whose plates each print in one colour needs no change, and a slice that reports no
|
|
16
|
+
* filament change is never refused.
|
|
17
|
+
* - Unknown when there are no printer credentials, the printer can't be reached, the caller said
|
|
18
|
+
* use_printer_filaments: false, or the printer isn't a Bambu. Then the slice succeeds, flagged: the colours and the
|
|
19
|
+
* filament changes are in the result and its message, so a client never sends it on silently.
|
|
20
|
+
* - Known too few feeds: the slice is refused with needs-more-filaments, as 1.1.97 refuses more colours than slots,
|
|
21
|
+
* unless the caller says the person will change filament by hand (manual_filament_changes: true).
|
|
22
|
+
*/
|
|
23
|
+
import { FilamentSlotsError } from "../refusal.js";
|
|
24
|
+
export interface PrinterFeed {
|
|
25
|
+
known: boolean;
|
|
26
|
+
/** AMS trays the printer reports (0: no AMS). */
|
|
27
|
+
ams_slots: number;
|
|
28
|
+
/** External spool holders: one per nozzle. */
|
|
29
|
+
external: number;
|
|
30
|
+
/** How it was known, or why it isn't. */
|
|
31
|
+
source: string;
|
|
32
|
+
}
|
|
33
|
+
/** The feeds a connected Bambu printer's raw report shows. */
|
|
34
|
+
export declare function feedFromBambuReport(raw: unknown, connected: boolean, dualNozzle: boolean): PrinterFeed;
|
|
35
|
+
export declare const UNKNOWN_FEED: (source: string, dualNozzle?: boolean) => PrinterFeed;
|
|
36
|
+
/**
|
|
37
|
+
* The colours a slice prints with and its filament changes, from Bambu Studio / OrcaSlicer's result.json: the most
|
|
38
|
+
* colours any one plate prints with (each plate prints on its own), and the changes of every plate that prints in
|
|
39
|
+
* more than one, added up, so a second plate's changes are never left out (Codex review, #170).
|
|
40
|
+
*/
|
|
41
|
+
export declare function sliceColours(result: unknown): {
|
|
42
|
+
colours: number;
|
|
43
|
+
changes: number | undefined;
|
|
44
|
+
};
|
|
45
|
+
export interface FeedVerdict {
|
|
46
|
+
/** The structured facts every multi-colour slice carries (additive). */
|
|
47
|
+
facts?: {
|
|
48
|
+
colours: number;
|
|
49
|
+
filament_changes?: number;
|
|
50
|
+
printer: "feeds-all" | "too-few-feeds" | "unknown";
|
|
51
|
+
feeds?: number;
|
|
52
|
+
source: string;
|
|
53
|
+
manual?: true;
|
|
54
|
+
};
|
|
55
|
+
/** A sentence for slicer_report.message on a slice that worked. */
|
|
56
|
+
note?: string;
|
|
57
|
+
/** The refusal, when the printer is known not to feed the colours and the caller didn't accept manual changes. */
|
|
58
|
+
refusal?: FilamentSlotsError;
|
|
59
|
+
}
|
|
60
|
+
/** The verdict on one slice: nothing for a one-colour slice. */
|
|
61
|
+
export declare function feedVerdict(result: unknown, feed: PrinterFeed, manual: boolean): FeedVerdict;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the printer can feed a multi-colour slice itself (beta 8 DAD replay, Nov 17): a two-colour 3MF sliced for a
|
|
3
|
+
* P1S with no AMS succeeded with 85 filament changes and no word, so a tester would have been sent a print that stops
|
|
4
|
+
* 85 times for a manual swap. Shared by bambu-printer-mcp and mcp-3D-printer-server.
|
|
5
|
+
*
|
|
6
|
+
* How the printer's feeds are known (the judgement, written down):
|
|
7
|
+
* - Feeds are the AMS trays the printer reports (every tray of every AMS unit, loaded or not: a person can load an
|
|
8
|
+
* empty one). Without an AMS, its external spool holders, one per nozzle (two on a dual-nozzle model). A print
|
|
9
|
+
* doesn't mix the external spool with AMS trays, so the two are not added. Two external spools feed two colours
|
|
10
|
+
* only when each colour is on its own nozzle; the slice's nozzle bindings aren't read here, so a dual-nozzle
|
|
11
|
+
* printer without an AMS is unknown for two colours (flagged, not passed) and too few for three.
|
|
12
|
+
* - Known only from a connected printer's report that carries its AMS block; one that lists no AMS unit in it means
|
|
13
|
+
* no AMS. A report without the block says nothing. The model alone never decides it: every model's AMS is
|
|
14
|
+
* optional.
|
|
15
|
+
* - Counted per plate: a project whose plates each print in one colour needs no change, and a slice that reports no
|
|
16
|
+
* filament change is never refused.
|
|
17
|
+
* - Unknown when there are no printer credentials, the printer can't be reached, the caller said
|
|
18
|
+
* use_printer_filaments: false, or the printer isn't a Bambu. Then the slice succeeds, flagged: the colours and the
|
|
19
|
+
* filament changes are in the result and its message, so a client never sends it on silently.
|
|
20
|
+
* - Known too few feeds: the slice is refused with needs-more-filaments, as 1.1.97 refuses more colours than slots,
|
|
21
|
+
* unless the caller says the person will change filament by hand (manual_filament_changes: true).
|
|
22
|
+
*/
|
|
23
|
+
import { FilamentSlotsError } from "../refusal.js";
|
|
24
|
+
/** The feeds a connected Bambu printer's raw report shows. */
|
|
25
|
+
export function feedFromBambuReport(raw, connected, dualNozzle) {
|
|
26
|
+
const report = raw && typeof raw === "object" ? raw : undefined;
|
|
27
|
+
const external = dualNozzle ? 2 : 1;
|
|
28
|
+
const block = report?.ams && typeof report.ams === "object" ? report.ams : undefined;
|
|
29
|
+
if (!connected || !block)
|
|
30
|
+
return { known: false, ams_slots: 0, external, source: connected ? "the printer's report has no AMS block yet" : "the printer's report could not be read" };
|
|
31
|
+
// Absence needs evidence: the unit list itself, or ams_exist_bits of zero. A partial block (an incremental push with
|
|
32
|
+
// tray_now but no list) says nothing, and stays unknown (Codex review, #170).
|
|
33
|
+
const noneExist = block.ams_exist_bits !== undefined && Number.parseInt(String(block.ams_exist_bits), 16) === 0;
|
|
34
|
+
if (!Array.isArray(block.ams) && !noneExist)
|
|
35
|
+
return { known: false, ams_slots: 0, external, source: "the printer's report doesn't list its AMS units yet" };
|
|
36
|
+
const units = Array.isArray(block.ams) ? block.ams : [];
|
|
37
|
+
// A unit's own tray list when it reports one; without it, one slot for an AMS HT (ids from 128, as ams-mapping.ts
|
|
38
|
+
// numbers them) and four for an AMS.
|
|
39
|
+
const slots = units.reduce((sum, unit) => {
|
|
40
|
+
const u = unit;
|
|
41
|
+
return sum + (Array.isArray(u?.tray) ? u.tray.length : Number.parseInt(String(u?.id ?? "0"), 10) >= 128 ? 1 : 4);
|
|
42
|
+
}, 0);
|
|
43
|
+
return { known: true, ams_slots: slots, external, source: slots ? `the printer reports ${units.length} AMS unit${units.length === 1 ? "" : "s"}` : "the printer reports no AMS" };
|
|
44
|
+
}
|
|
45
|
+
export const UNKNOWN_FEED = (source, dualNozzle = false) => ({ known: false, ams_slots: 0, external: dualNozzle ? 2 : 1, source });
|
|
46
|
+
/**
|
|
47
|
+
* The colours a slice prints with and its filament changes, from Bambu Studio / OrcaSlicer's result.json: the most
|
|
48
|
+
* colours any one plate prints with (each plate prints on its own), and the changes of every plate that prints in
|
|
49
|
+
* more than one, added up, so a second plate's changes are never left out (Codex review, #170).
|
|
50
|
+
*/
|
|
51
|
+
export function sliceColours(result) {
|
|
52
|
+
const plates = result && typeof result === "object" && Array.isArray(result.sliced_plates)
|
|
53
|
+
? result.sliced_plates : [];
|
|
54
|
+
let colours = 0;
|
|
55
|
+
let changes;
|
|
56
|
+
for (const plate of plates) {
|
|
57
|
+
const used = new Set();
|
|
58
|
+
for (const f of Array.isArray(plate?.filaments) ? plate.filaments : [])
|
|
59
|
+
if (typeof f?.id === "number" && (typeof f.total_used_g !== "number" || f.total_used_g > 0))
|
|
60
|
+
used.add(f.id);
|
|
61
|
+
colours = Math.max(colours, used.size);
|
|
62
|
+
if (used.size > 1 && typeof plate?.filament_change_times === "number")
|
|
63
|
+
changes = (changes ?? 0) + plate.filament_change_times;
|
|
64
|
+
}
|
|
65
|
+
return { colours, changes: colours > 1 ? changes : plates.some(p => typeof p?.filament_change_times === "number") ? 0 : undefined };
|
|
66
|
+
}
|
|
67
|
+
/** The verdict on one slice: nothing for a one-colour slice. */
|
|
68
|
+
export function feedVerdict(result, feed, manual) {
|
|
69
|
+
const { colours, changes } = sliceColours(result);
|
|
70
|
+
// One colour on every plate, or a slice that changes filament nowhere, stops for nothing.
|
|
71
|
+
if (colours < 2 || changes === 0)
|
|
72
|
+
return {};
|
|
73
|
+
const feeds = feed.ams_slots > 0 ? feed.ams_slots : feed.external;
|
|
74
|
+
const base = { colours, ...(changes !== undefined ? { filament_changes: changes } : {}), source: feed.source };
|
|
75
|
+
const stops = changes !== undefined ? `${changes} time${changes === 1 ? "" : "s"}` : "at each colour change";
|
|
76
|
+
if (!feed.known)
|
|
77
|
+
return { facts: { ...base, printer: "unknown" },
|
|
78
|
+
note: `This prints in ${colours} colours${changes !== undefined ? ` and changes filament ${changes} time${changes === 1 ? "" : "s"}` : ""}. Without an AMS, the printer stops ${changes !== undefined ? "for each change" : "at each colour change"} for you to swap filament: print it in one colour, or each colour as its own part.` };
|
|
79
|
+
if (feed.ams_slots === 0 && feed.external > 1 && colours <= feed.external)
|
|
80
|
+
return { facts: { ...base, printer: "unknown", feeds, source: `${feed.source}; its ${feed.external} external spools feed ${colours} colours only with each colour on its own nozzle` },
|
|
81
|
+
note: `This prints in ${colours} colours. Without an AMS it needs each colour on its own nozzle, or it stops ${stops} for you to swap filament.` };
|
|
82
|
+
// A dual-nozzle printer can also feed its other nozzle's external spool beside its AMS trays, depending on the plate's
|
|
83
|
+
// nozzle bindings, which aren't read here (Codex review, #170): those colours are flagged, not refused.
|
|
84
|
+
if (feed.ams_slots > 0 && feed.external > 1 && colours > feeds && colours <= feeds + feed.external - 1)
|
|
85
|
+
return { facts: { ...base, printer: "unknown", feeds: feeds + feed.external - 1, source: `${feed.source}; the other nozzle's external spool can feed one more colour, depending on the plate's nozzle bindings` },
|
|
86
|
+
note: `This prints in ${colours} colours, one more than the AMS holds. It needs that colour on the other nozzle's external spool, or it stops for you to swap filament.` };
|
|
87
|
+
if (feeds >= colours)
|
|
88
|
+
return { facts: { ...base, printer: "feeds-all", feeds } };
|
|
89
|
+
const plain = feed.ams_slots === 0
|
|
90
|
+
? `This prints in ${colours} colours. Your printer has no AMS, so it would stop ${stops} for you to change filament. Print it in one colour instead, or print each colour as its own part.`
|
|
91
|
+
: `This prints in ${colours} colours, but your printer can hold ${feeds} filaments, so it would stop for you to change filament by hand. Print it in fewer colours, or print each colour as its own part.`;
|
|
92
|
+
if (manual)
|
|
93
|
+
return { facts: { ...base, printer: "too-few-feeds", feeds, manual: true },
|
|
94
|
+
note: feed.ams_slots === 0 ? `Your printer has no AMS, so this print stops ${stops} for you to change filament.` : `This print stops for you to change filament by hand.` };
|
|
95
|
+
const facts = { ...base, printer: "too-few-feeds", feeds };
|
|
96
|
+
const refusal = new FilamentSlotsError(colours, feeds, { plain, changes });
|
|
97
|
+
refusal.feed = facts;
|
|
98
|
+
return { facts, refusal };
|
|
99
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bambu-printer-mcp",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.98",
|
|
4
4
|
"description": "MCP server for Bambu Lab 3D printers with STL manipulation, slicing, and print management",
|
|
5
5
|
"counterpart": {
|
|
6
6
|
"contract": "counterpart/1",
|
|
7
|
-
"notes": "
|
|
7
|
+
"notes": "Refuses or flags a multi-colour slice the printer can't feed, saying how many times it would stop, and makes copies in one colour on a printer without an AMS.",
|
|
8
8
|
"autoUpdate": true
|
|
9
9
|
},
|
|
10
10
|
"main": "dist/index.js",
|
package/src/cad/contracts.ts
CHANGED
|
@@ -431,7 +431,7 @@ Measure a scan once, before designing from it: one check run (role: "check", mod
|
|
|
431
431
|
Fit reference workflow: return load_scan("scan", source_units="m", up_axis="y") from build() in mode: "mesh" to export an unchanged, prepared reference STL for cad_check_fit. Declare every linked OBJ/MTL/texture asset. If you crop, simplify, fill, or otherwise alter this reference, report exactly what you excluded/changed and that the fit check proves only that reduced reference in the stated pose. A fit check against a scan is information; it must never resize or override an interface specified by measured dimensions. Keep those measured interfaces and report the discrepancy.
|
|
432
432
|
Result selection and edits: set final: true only on the result you select. cad-result.json in each immediate run folder is protected from script writes and retains final, completed_at, lineage_id (source hash), full checks and artifact paths; clients can discover the latest completed final record after restart without rebuilding. Final is a selection marker, not a replacement for valid/checks. Queued calls may expire with cad-queue-timeout before dispatch; do not automatically replay. Unchanged declared files reuse a read-only content-addressed bundle under output_dir/.cad-inputs, preserving filenames and restricting reads to that bundle. Keep this shared cache with the saved runs.
|
|
433
433
|
Mesh cleanup workflow: return a trimesh.Trimesh in mode: "mesh". Load the prepared mesh, fit needed geometry with NumPy/SciPy, rebuild regular sections/features with build123d or manifold3d CrossSection/extrusion/revolve, and combine meshes with manifold3d booleans. scikit-image supplies marching cubes for voxel/SDF work; Shapely supplies planar operations; Pillow supplies image/texture reads. Keep numeric choices in P and regenerate from declared inputs. Validate closure, winding, manifold status, dimensions and all six views using cad_run. What to regularise, infer, preserve or label comes from the caller's cleanup rules, not this engine prompt.
|
|
434
|
-
Multi-colour 3MF projects: build() may return project_3mf() instead of a shape. A new project: p = project_3mf(); p.add_part(shape, name="Lid", filament=2, color="#1A1A1A", object="Box", plate=1) for each part (parts that share object= are one object, printed as one piece; plates from 1; color, given for every part or none, declares each filament's colour in the 3MF), in solid mode with build123d shapes (the checks fuse each object's parts) or mode: "mesh" with trimesh parts. Editing a designer's 3MF: declare it as an input and p = project_3mf("kit") in mode: "mesh"; p.objects lists its objects (name, id, plate; p.object(id or unique name)) and their parts (name, id, filament, painted, mesh: a trimesh in the object's frame); p.add_part(shape, name=..., filament=..., object="Body") adds a part in that object's frame, p.replace_part(part, mesh) swaps a part's mesh (its painting goes with the old mesh) and p.set_part(part, name=..., filament=...) renames or recolours one; everything else in the file (print settings, painting, plates, other parts) is kept. cad_run writes <name>.3mf beside the STL and returns three_mf and three_mf_project (each plate's parts and filaments, read back from the file); slice it with slice_stl, never by rebuilding it from the STL. A design in several colours gets them from the same run as the model: build() returns project_3mf() with one add_part per colour body, so one cad_run builds the shape once and writes the STL and the 3MF together. Never re-run the whole script once per colour to export each colour's STL: that repeats the full build for every colour.
|
|
434
|
+
Multi-colour 3MF projects: build() may return project_3mf() instead of a shape. A new project: p = project_3mf(); p.add_part(shape, name="Lid", filament=2, color="#1A1A1A", object="Box", plate=1) for each part (parts that share object= are one object, printed as one piece; plates from 1; color, given for every part or none, declares each filament's colour in the 3MF), in solid mode with build123d shapes (the checks fuse each object's parts) or mode: "mesh" with trimesh parts. Editing a designer's 3MF: declare it as an input and p = project_3mf("kit") in mode: "mesh"; p.objects lists its objects (name, id, plate; p.object(id or unique name)) and their parts (name, id, filament, painted, mesh: a trimesh in the object's frame); p.add_part(shape, name=..., filament=..., object="Body") adds a part in that object's frame, p.replace_part(part, mesh) swaps a part's mesh (its painting goes with the old mesh) and p.set_part(part, name=..., filament=...) renames or recolours one; everything else in the file (print settings, painting, plates, other parts) is kept. cad_run writes <name>.3mf beside the STL and returns three_mf and three_mf_project (each plate's parts and filaments, read back from the file); slice it with slice_stl, never by rebuilding it from the STL. A design gets several colours only when the printer can feed them (fdm_multicolor: one colour by default on a printer without an AMS, and the summary says why). A design in several colours gets them from the same run as the model: build() returns project_3mf() with one add_part per colour body, so one cad_run builds the shape once and writes the STL and the 3MF together. Never re-run the whole script once per colour to export each colour's STL: that repeats the full build for every colour.
|
|
435
435
|
Captured scan touch-up: t = scan_touchup(load_scan("scan", source_units="m", up_axis="y", ground=False), colour="colour", normal="normal", edge_mm=0.4) takes a textured capture (declare its OBJ, MTL and colour and normal map PNGs as inputs; pass the map aliases). It removes loose pieces and spikes, closes holes and refines to edge_mm without shrinking the body. t.regions() prints the colour regions (id, colour, area, size, flatness; 0 is the body) to build.log and saves regions.png in the run folder: read both, then name regions by id in the same scan and edge_mm. t.flatten(ids, shape="plane" or "curved"), t.bead(id, diameter_mm, proud_mm), t.cord(id, diameter_mm, proud_mm) (a cord follows its region's own curve) and t.seat(height_mm) record steps; return t.mesh(relief_gain=1.0), which adds the normal map's measured relief, applies the steps with manifold3d and prints its changes. Keep relief_gain at 1: a larger gain amplifies the map's noise, not stitches. When the caller's rules call for a textile's relief the scan missed (fabric, knit, crochet the photos show raised), t.texture_relief(height_mm, regions=None) raises its stitch pattern from the colour texture on the textile only (never flattened, beaded or corded regions); about 0.6 to 1.0 mm peak to peak prints visibly. It is off unless called: never for hard objects, printed graphics or labels.
|
|
436
436
|
The result includes paths, millimetre bounds/size, mesh and STEP volumes, solid count, watertight/manifold/winding/STEP checks, bodies (closest approach between solids, contact with the print plate at Z = 0, labelled bodies that are not one solid), problems, checked and not_checked, six orthographic renders (front, back, left, right, top, bottom), a perspective view from the front right and above, and a contact sheet with the perspective view large beside the six. Fix every entry in problems before selecting a result; an empty problems list proves nothing listed in not_checked. After every cad_run, Read its perspective view (renders.perspective, as the result's next says) before the next cad_run or any other change: a run you have not looked at tells you nothing about the form. Judge the form from the perspective view first: would a person recognise the product and want it? Then inspect all six; revise visible defects. Before the final run, list what the views show is wrong against the bought product you named (for a scan, the object in its photos), and fix each one or report it. To get a number out of a design (a spring force, a strain, a clearance you derived), print() it in the script: the result returns it as printed, with no need to make a run fail. A valid mesh or nominal parameter does not prove the requested dimension: measure the actual exported interfaces. Use cad_check_fit on a model and reference STL with an explicit rigid transform; report raw-scan interference and minimum gap. Calipers are authoritative but disagreement with a scan is unresolved measurement evidence, not permission to silently rescale it. Check assembly/insertion paths and actual articulated poses, not sums of local joint limits or reference points alone. Printing, clearance under load, supports and motion need separate evidence.
|
|
437
437
|
Fit, flexure and thread parameters: put each interface's nominal size, its source (measured, published, or assumed), the print correction, and the design fit in P as separate named values, so a fit report revises one number without resending the script. Model every dimension you claim: a parameter the geometry never uses (a wallet or case width that no cut or wall reads) is a defect; use it or remove it. Shape flexures so their bending lies in the layer plane of the exported print orientation, with the stroke, preload, and hard-stop gap as P values; build the stopped pose as well as the rest pose when checking. Model printed threads as explicit coarse geometry with the same pitch on both sides and clearance as a radial P offset; never scale a screw to clear its hole.
|
package/src/design-guidance.ts
CHANGED
|
@@ -52,6 +52,8 @@ Keep the user-facing result short: the recommended design, why its manufacturing
|
|
|
52
52
|
|
|
53
53
|
export const FDM_MULTICOLOR = `Apply this guidance when multiple colors or support materials share a print.
|
|
54
54
|
|
|
55
|
+
First check that the printer can feed the colours itself. get_printer_filaments lists its AMS trays: a connected printer with none has no AMS and feeds one filament at a time, or one per nozzle on a dual-nozzle printer. When it can't feed them (no AMS or other multi-material unit, or fewer filaments than colours), make the design in one colour by default, even a copy of an object the photos show in several, because every colour change would stop the print for a manual swap. Say why in the summary in plain words, for example: "Your printer has no AMS, so it's one colour; ask for two colours if you'll change filament by hand." Make it in colours only when the person asks for them; then slice with manual_filament_changes: true and say how many times it stops (filament_changes in the slice result). When you can't tell whether the printer has an AMS, keep the colours and say that without an AMS it stops at each colour change. slice_stl refuses a slice in more colours than the printer is known to feed (needs-more-filaments) and flags one it can't check.
|
|
56
|
+
|
|
55
57
|
Preserve the requested visual pattern. Evaluate its colors in build coordinates and across layers before committing to color geometry. On a shared nozzle, a small accent spanning many layers can create more transitions than a large region confined to a few layers. Count the slicer's actual transitions when available, including swaps back to a prior filament and support-interface swaps; color count and colored volume are only screening clues. On printers with multiple nozzles, evaluate each shared melt path; AMS slots are not independent nozzles.
|
|
56
58
|
|
|
57
59
|
For a costly pattern, consider the most promising alternatives: a different build orientation, color regions confined to fewer layers, shallow face inlays, or separately printed single-color pieces with intentional assembly. A vertical stripe in use may become a low-change feature in a different print orientation. Judge each option against load direction, surface quality, support burden, and the user's exact visual requirements. Finer layers can help an overhang while adding color-change layers; evaluate local adaptive layers and re-slice the combined plan.
|
|
@@ -406,6 +408,7 @@ export function slicingGuidance(slicerType: string, capabilities: { supports: bo
|
|
|
406
408
|
capabilities.orient
|
|
407
409
|
? `- Orientation: slice_stl with orient true lets ${slicer}'s own auto-orient choose how an STL sits on the bed. It keeps overhang area low; it does not check cantilevers. To see what it chooses, slice the checkpoint with orient true. When a print is oriented this way, don't promise a particular orientation on the bed: the slicer chooses it.`
|
|
408
410
|
: `- Orientation: ${slicer} doesn't auto-orient here. An STL prints in the orientation it's exported in.`,
|
|
411
|
+
"- Colours: a slice in more colours than the printer can feed (no AMS, or fewer filaments than colours) is refused with needs-more-filaments, its filament_changes and a plain message; when the printer can't be asked it succeeds with filament_feed and a note. One colour is the default on such a printer (fdm_multicolor); slice with manual_filament_changes: true only when the person will change filament by hand.",
|
|
409
412
|
capabilities.supports
|
|
410
413
|
? "- Supports: set enable_support on every slice_stl call. With enable_support true it generates supports in the style support_type names (tree(auto) or normal(auto)); with false it generates none; left out, the process preset's own setting applies. Slice the checkpoint with enable_support set the way the print will be sliced. A print gets the supports it was sliced with: print the sliced file itself, or slice the print with slice_stl and the same enable_support and support_type. print_3mf's own slicing of a file that isn't sliced yet takes no support settings; it uses the process profile's."
|
|
411
414
|
: `- Supports: ${slicer} takes no support settings from slice_stl here: whether it generates supports is its configured profile's own setting. Slice a checkpoint to see what that profile does before modeling any support yourself.`,
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { withRemote } from "./counterpart/remote.js";
|
|
|
8
8
|
import { refusalReport, slicedFileFacts, slicerReport } from "./counterpart/sliced-file.js";
|
|
9
9
|
import { listModelPlates } from "./counterpart/model-plates.js";
|
|
10
10
|
import { floatingWarningFacts } from "./slicer/floating-regions.js";
|
|
11
|
+
import { feedFromBambuReport, feedVerdict, sliceColours, UNKNOWN_FEED, type PrinterFeed } from "./slicer/filament-feed.js";
|
|
11
12
|
|
|
12
13
|
/** The slicer's verdict beside its result.json (`slicer_report`). */
|
|
13
14
|
function reportOf(result: unknown): { slicer_report?: ReturnType<typeof slicerReport> } {
|
|
@@ -2156,6 +2157,31 @@ class BambuPrinterMCPServer {
|
|
|
2156
2157
|
});
|
|
2157
2158
|
}
|
|
2158
2159
|
|
|
2160
|
+
/**
|
|
2161
|
+
* The filaments the configured printer can feed itself, for a multi-colour slice (src/slicer/filament-feed.ts):
|
|
2162
|
+
* its AMS trays and external spools from a fresh report, or unknown without one. Only reads status.
|
|
2163
|
+
*/
|
|
2164
|
+
private async printerFeed(usePrinterFilaments: boolean, model: string, host: string, bambuSerial: string | undefined, bambuToken: string | undefined): Promise<PrinterFeed> {
|
|
2165
|
+
const dual = isDualNozzleModel(model);
|
|
2166
|
+
const unknown = (source: string) => UNKNOWN_FEED(source, dual);
|
|
2167
|
+
if (!usePrinterFilaments) return unknown("use_printer_filaments is false, so the printer wasn't asked");
|
|
2168
|
+
if (!bambuSerial || !bambuToken) return unknown("no printer is configured to ask");
|
|
2169
|
+
try {
|
|
2170
|
+
let status = await this.bambu.getStatus(host, bambuSerial, bambuToken);
|
|
2171
|
+
let feed = feedFromBambuReport(status?.raw, status?.connected === true, dual);
|
|
2172
|
+
// An idle printer's first push can be sparse; its AMS block follows (as get_printer_filaments waits for). A
|
|
2173
|
+
// printer that isn't connected isn't asked twice.
|
|
2174
|
+
if (status?.connected === true && (!feed.known || feed.ams_slots === 0)) {
|
|
2175
|
+
await new Promise(resolve => setTimeout(resolve, 1500));
|
|
2176
|
+
status = await this.bambu.getStatus(host, bambuSerial, bambuToken);
|
|
2177
|
+
feed = feedFromBambuReport(status?.raw, status?.connected === true, dual);
|
|
2178
|
+
}
|
|
2179
|
+
return feed;
|
|
2180
|
+
} catch {
|
|
2181
|
+
return unknown("the printer could not be reached");
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2159
2185
|
private async getResolvedPrinterFilamentInventory(
|
|
2160
2186
|
host: string,
|
|
2161
2187
|
bambuSerial: string,
|
|
@@ -2810,11 +2836,12 @@ class BambuPrinterMCPServer {
|
|
|
2810
2836
|
},
|
|
2811
2837
|
{
|
|
2812
2838
|
name: "slice_stl",
|
|
2813
|
-
description: "Slice an STL or 3MF file using a slicer to generate printable G-code or sliced 3MF. IMPORTANT: bambu_model must be specified to ensure the slicer generates safe G-code for the correct printer. The text result is the sliced file's path. When Bambu Studio or OrcaSlicer writes a result.json, structuredContent.slicer_result carries it verbatim, success or error: error_string, return_code and each sliced_plates[].warning_message, such as a floating cantilever. structuredContent.slicer_report says whether it failed; for a failure, its message is a plain sentence for a person and slicer_message keeps the slicer's words, which a failed slice's text gives after that sentence. When a slice that worked warns of floating regions, next carries the stop rule (one targeted fix and one re-slice, then report it or slice with supports on) and, for an STL the slicer did not turn, structuredContent.floating_regions lists where they are: x and y in the STL's own millimetres, z above its lowest point, and depth_mm, how far each hangs below where it joins the rest. A 3MF that carries its own process settings (a designer's Bambu Studio or Orca project) slices with them unless slicer_profile, template_name or template_3mf_path is given; the machine still comes from bambu_model. quality and strength adjust that process, and strength never lowers its walls or infill.",
|
|
2839
|
+
description: "Slice an STL or 3MF file using a slicer to generate printable G-code or sliced 3MF. IMPORTANT: bambu_model must be specified to ensure the slicer generates safe G-code for the correct printer. The text result is the sliced file's path. When Bambu Studio or OrcaSlicer writes a result.json, structuredContent.slicer_result carries it verbatim, success or error: error_string, return_code and each sliced_plates[].warning_message, such as a floating cantilever. structuredContent.slicer_report says whether it failed; for a failure, its message is a plain sentence for a person and slicer_message keeps the slicer's words, which a failed slice's text gives after that sentence. When a slice that worked warns of floating regions, next carries the stop rule (one targeted fix and one re-slice, then report it or slice with supports on) and, for an STL the slicer did not turn, structuredContent.floating_regions lists where they are: x and y in the STL's own millimetres, z above its lowest point, and depth_mm, how far each hangs below where it joins the rest. A slice in two or more colours carries filament_feed: the colours, the filament changes the slicer reports, and whether the printer can feed them (its AMS trays and external spools from a fresh status read; unknown without one). When the printer is known not to (no AMS, or fewer filaments than colours), slice_stl refuses with code needs-more-filaments, filament_slots, filament_changes and a plain slicer_report.message, unless manual_filament_changes is true; when it is unknown, the slice succeeds and slicer_report.message says how many times it would stop without an AMS. A 3MF that carries its own process settings (a designer's Bambu Studio or Orca project) slices with them unless slicer_profile, template_name or template_3mf_path is given; the machine still comes from bambu_model. quality and strength adjust that process, and strength never lowers its walls or infill.",
|
|
2814
2840
|
inputSchema: {
|
|
2815
2841
|
type: "object",
|
|
2816
2842
|
properties: {
|
|
2817
2843
|
stl_path: { type: "string", description: "Path to the STL or 3MF file to slice" },
|
|
2844
|
+
manual_filament_changes: { type: "boolean", description: "The person will change filament by hand: a slice in more colours than the printer can feed (no AMS) is returned, with the number of changes, instead of refused with needs-more-filaments." },
|
|
2818
2845
|
bambu_model: {
|
|
2819
2846
|
type: "string",
|
|
2820
2847
|
enum: [...VALID_BAMBU_MODELS],
|
|
@@ -4748,7 +4775,17 @@ class BambuPrinterMCPServer {
|
|
|
4748
4775
|
const turned = Boolean(args?.orient) || [args?.rotate, args?.rotate_x, args?.rotate_y].some(r => r !== undefined && Number(r) !== 0)
|
|
4749
4776
|
|| (args?.scale !== undefined && Number(args.scale) !== 1);
|
|
4750
4777
|
const located = await floatingWarningFacts(reported.slicer_report, String(args.stl_path), turned);
|
|
4751
|
-
|
|
4778
|
+
// A slice in several colours on a printer that can't feed them is refused or flagged, never sent on
|
|
4779
|
+
// silently (beta 8 DAD replay: 85 manual changes on a P1S with no AMS). See src/slicer/filament-feed.ts.
|
|
4780
|
+
let feedFacts: Record<string, unknown> = {};
|
|
4781
|
+
if (sliceColours(sliced.slicer_result).colours >= 2) {
|
|
4782
|
+
const verdict = feedVerdict(sliced.slicer_result, await this.printerFeed(usePrinterFilaments, sliceModel, host, bambuSerial, bambuToken), args?.manual_filament_changes === true);
|
|
4783
|
+
if (verdict.refusal) throw Object.assign(verdict.refusal, { slicerResult: sliced.slicer_result });
|
|
4784
|
+
if (verdict.facts) feedFacts = { filament_feed: verdict.facts };
|
|
4785
|
+
if (verdict.note && reported.slicer_report)
|
|
4786
|
+
reported.slicer_report = { ...reported.slicer_report, message: reported.slicer_report.message ? `${reported.slicer_report.message}\n${verdict.note}` : verdict.note };
|
|
4787
|
+
}
|
|
4788
|
+
return { content: [{ type: "text", text: sliced.path }], structuredContent: { ...reported, ...located, ...feedFacts } };
|
|
4752
4789
|
}
|
|
4753
4790
|
|
|
4754
4791
|
case "print_3mf": {
|
|
@@ -5307,13 +5344,17 @@ class BambuPrinterMCPServer {
|
|
|
5307
5344
|
// A slicer failure always carries slicer_report: the plain sentence a person sees, the slicer's words for the log.
|
|
5308
5345
|
// The report always says failed (a result.json that says success can still leave no output file).
|
|
5309
5346
|
...(error instanceof SlicerRunError ? {
|
|
5310
|
-
...(error.slicerResult ? { slicer_result: error.slicerResult } : {}),
|
|
5347
|
+
...(error.slicerResult ? { slicer_result: error.slicerResult as Record<string, unknown> } : {}),
|
|
5311
5348
|
slicer_report: { ...refusalReport(error.words), message: error.plain ?? error.words.slice(0, 2000) },
|
|
5312
5349
|
} : {}),
|
|
5313
5350
|
// A design in more colours than filaments to slice it with: the counts and the plain answer a client shows.
|
|
5314
5351
|
...(error instanceof FilamentSlotsError ? {
|
|
5315
5352
|
filament_slots: { colours: error.colours, slots: error.slots },
|
|
5316
|
-
|
|
5353
|
+
...(error.changes !== undefined ? { filament_changes: error.changes } : {}),
|
|
5354
|
+
...(error.feed ? { filament_feed: error.feed } : {}),
|
|
5355
|
+
...(error.slicerResult ? { slicer_result: error.slicerResult as Record<string, unknown> } : {}),
|
|
5356
|
+
...(error.feed ? { suggestion: "Make it in one colour, or print each colour as its own part. If the person will change filament by hand, slice again with manual_filament_changes: true." } : {}),
|
|
5357
|
+
slicer_report: { failed: true, message: error.plain, slicer_message: error.detail },
|
|
5317
5358
|
} : {}),
|
|
5318
5359
|
};
|
|
5319
5360
|
|
package/src/refusal.ts
CHANGED
|
@@ -57,10 +57,28 @@ export function printOutcome(error: unknown): PrintOutcome {
|
|
|
57
57
|
*/
|
|
58
58
|
export class FilamentSlotsError extends PrinterRefusal {
|
|
59
59
|
readonly plain: string;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
/** The filament changes the slice would make, when the slicer reported them (a printer with too few feeds). */
|
|
61
|
+
readonly changes?: number;
|
|
62
|
+
/** The slicer's own words, or this server's when the printer's feeds decided it. */
|
|
63
|
+
readonly detail: string;
|
|
64
|
+
/** The printer's feeds and the slice's colours, when they decided it (slice_stl's filament_feed). */
|
|
65
|
+
feed?: Record<string, unknown>;
|
|
66
|
+
/** The slicer's own result.json for the slice the printer's feeds refused. */
|
|
67
|
+
slicerResult?: unknown;
|
|
68
|
+
/**
|
|
69
|
+
* colours: the colours the design prints with; slots: the filaments there are to feed them (slice slots, or the
|
|
70
|
+
* printer's AMS trays plus external spools). `options` carries the plain sentence when the printer's feeds decide
|
|
71
|
+
* it, and the filament changes the slice would make.
|
|
72
|
+
*/
|
|
73
|
+
constructor(readonly colours: number, readonly slots: number, options: { plain?: string; changes?: number } = {}) {
|
|
74
|
+
const plain = options.plain ?? `This design is in ${colours} colours, but only ${slots} filament${slots === 1 ? " is" : "s are"} available to print it. It needs a printer with an AMS loaded with ${colours} colours, or it can print in one colour.`;
|
|
75
|
+
const detail = options.plain
|
|
76
|
+
? `The design prints in ${colours} filaments and the printer can feed ${slots}${options.changes !== undefined ? `; the slice makes ${options.changes} filament changes` : ""}.`
|
|
77
|
+
: `${colours} filament colours were supplied for ${slots} filament slots.`;
|
|
78
|
+
super("needs-more-filaments", `${plain}\n${options.plain ? "The slice said" : "The slicer setup said"}: ${detail}`);
|
|
63
79
|
this.name = "FilamentSlotsError";
|
|
64
80
|
this.plain = plain;
|
|
81
|
+
this.detail = detail;
|
|
82
|
+
if (options.changes !== undefined) this.changes = options.changes;
|
|
65
83
|
}
|
|
66
84
|
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the printer can feed a multi-colour slice itself (beta 8 DAD replay, Nov 17): a two-colour 3MF sliced for a
|
|
3
|
+
* P1S with no AMS succeeded with 85 filament changes and no word, so a tester would have been sent a print that stops
|
|
4
|
+
* 85 times for a manual swap. Shared by bambu-printer-mcp and mcp-3D-printer-server.
|
|
5
|
+
*
|
|
6
|
+
* How the printer's feeds are known (the judgement, written down):
|
|
7
|
+
* - Feeds are the AMS trays the printer reports (every tray of every AMS unit, loaded or not: a person can load an
|
|
8
|
+
* empty one). Without an AMS, its external spool holders, one per nozzle (two on a dual-nozzle model). A print
|
|
9
|
+
* doesn't mix the external spool with AMS trays, so the two are not added. Two external spools feed two colours
|
|
10
|
+
* only when each colour is on its own nozzle; the slice's nozzle bindings aren't read here, so a dual-nozzle
|
|
11
|
+
* printer without an AMS is unknown for two colours (flagged, not passed) and too few for three.
|
|
12
|
+
* - Known only from a connected printer's report that carries its AMS block; one that lists no AMS unit in it means
|
|
13
|
+
* no AMS. A report without the block says nothing. The model alone never decides it: every model's AMS is
|
|
14
|
+
* optional.
|
|
15
|
+
* - Counted per plate: a project whose plates each print in one colour needs no change, and a slice that reports no
|
|
16
|
+
* filament change is never refused.
|
|
17
|
+
* - Unknown when there are no printer credentials, the printer can't be reached, the caller said
|
|
18
|
+
* use_printer_filaments: false, or the printer isn't a Bambu. Then the slice succeeds, flagged: the colours and the
|
|
19
|
+
* filament changes are in the result and its message, so a client never sends it on silently.
|
|
20
|
+
* - Known too few feeds: the slice is refused with needs-more-filaments, as 1.1.97 refuses more colours than slots,
|
|
21
|
+
* unless the caller says the person will change filament by hand (manual_filament_changes: true).
|
|
22
|
+
*/
|
|
23
|
+
import { FilamentSlotsError } from "../refusal.js";
|
|
24
|
+
|
|
25
|
+
export interface PrinterFeed {
|
|
26
|
+
known: boolean;
|
|
27
|
+
/** AMS trays the printer reports (0: no AMS). */
|
|
28
|
+
ams_slots: number;
|
|
29
|
+
/** External spool holders: one per nozzle. */
|
|
30
|
+
external: number;
|
|
31
|
+
/** How it was known, or why it isn't. */
|
|
32
|
+
source: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The feeds a connected Bambu printer's raw report shows. */
|
|
36
|
+
export function feedFromBambuReport(raw: unknown, connected: boolean, dualNozzle: boolean): PrinterFeed {
|
|
37
|
+
const report = raw && typeof raw === "object" ? raw as Record<string, unknown> : undefined;
|
|
38
|
+
const external = dualNozzle ? 2 : 1;
|
|
39
|
+
const block = report?.ams && typeof report.ams === "object" ? report.ams as Record<string, unknown> : undefined;
|
|
40
|
+
if (!connected || !block) return { known: false, ams_slots: 0, external, source: connected ? "the printer's report has no AMS block yet" : "the printer's report could not be read" };
|
|
41
|
+
// Absence needs evidence: the unit list itself, or ams_exist_bits of zero. A partial block (an incremental push with
|
|
42
|
+
// tray_now but no list) says nothing, and stays unknown (Codex review, #170).
|
|
43
|
+
const noneExist = block.ams_exist_bits !== undefined && Number.parseInt(String(block.ams_exist_bits), 16) === 0;
|
|
44
|
+
if (!Array.isArray(block.ams) && !noneExist) return { known: false, ams_slots: 0, external, source: "the printer's report doesn't list its AMS units yet" };
|
|
45
|
+
const units = Array.isArray(block.ams) ? block.ams : [];
|
|
46
|
+
// A unit's own tray list when it reports one; without it, one slot for an AMS HT (ids from 128, as ams-mapping.ts
|
|
47
|
+
// numbers them) and four for an AMS.
|
|
48
|
+
const slots = units.reduce((sum: number, unit) => {
|
|
49
|
+
const u = unit as { id?: unknown; tray?: unknown };
|
|
50
|
+
return sum + (Array.isArray(u?.tray) ? u.tray.length : Number.parseInt(String(u?.id ?? "0"), 10) >= 128 ? 1 : 4);
|
|
51
|
+
}, 0);
|
|
52
|
+
return { known: true, ams_slots: slots, external, source: slots ? `the printer reports ${units.length} AMS unit${units.length === 1 ? "" : "s"}` : "the printer reports no AMS" };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const UNKNOWN_FEED = (source: string, dualNozzle = false): PrinterFeed => ({ known: false, ams_slots: 0, external: dualNozzle ? 2 : 1, source });
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The colours a slice prints with and its filament changes, from Bambu Studio / OrcaSlicer's result.json: the most
|
|
59
|
+
* colours any one plate prints with (each plate prints on its own), and the changes of every plate that prints in
|
|
60
|
+
* more than one, added up, so a second plate's changes are never left out (Codex review, #170).
|
|
61
|
+
*/
|
|
62
|
+
export function sliceColours(result: unknown): { colours: number; changes: number | undefined } {
|
|
63
|
+
const plates = result && typeof result === "object" && Array.isArray((result as { sliced_plates?: unknown }).sliced_plates)
|
|
64
|
+
? (result as { sliced_plates: Record<string, unknown>[] }).sliced_plates : [];
|
|
65
|
+
let colours = 0;
|
|
66
|
+
let changes: number | undefined;
|
|
67
|
+
for (const plate of plates) {
|
|
68
|
+
const used = new Set<number>();
|
|
69
|
+
for (const f of Array.isArray(plate?.filaments) ? plate.filaments as Record<string, unknown>[] : [])
|
|
70
|
+
if (typeof f?.id === "number" && (typeof f.total_used_g !== "number" || f.total_used_g > 0)) used.add(f.id);
|
|
71
|
+
colours = Math.max(colours, used.size);
|
|
72
|
+
if (used.size > 1 && typeof plate?.filament_change_times === "number") changes = (changes ?? 0) + plate.filament_change_times;
|
|
73
|
+
}
|
|
74
|
+
return { colours, changes: colours > 1 ? changes : plates.some(p => typeof p?.filament_change_times === "number") ? 0 : undefined };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface FeedVerdict {
|
|
78
|
+
/** The structured facts every multi-colour slice carries (additive). */
|
|
79
|
+
facts?: { colours: number; filament_changes?: number; printer: "feeds-all" | "too-few-feeds" | "unknown"; feeds?: number; source: string; manual?: true };
|
|
80
|
+
/** A sentence for slicer_report.message on a slice that worked. */
|
|
81
|
+
note?: string;
|
|
82
|
+
/** The refusal, when the printer is known not to feed the colours and the caller didn't accept manual changes. */
|
|
83
|
+
refusal?: FilamentSlotsError;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The verdict on one slice: nothing for a one-colour slice. */
|
|
87
|
+
export function feedVerdict(result: unknown, feed: PrinterFeed, manual: boolean): FeedVerdict {
|
|
88
|
+
const { colours, changes } = sliceColours(result);
|
|
89
|
+
// One colour on every plate, or a slice that changes filament nowhere, stops for nothing.
|
|
90
|
+
if (colours < 2 || changes === 0) return {};
|
|
91
|
+
const feeds = feed.ams_slots > 0 ? feed.ams_slots : feed.external;
|
|
92
|
+
const base = { colours, ...(changes !== undefined ? { filament_changes: changes } : {}), source: feed.source };
|
|
93
|
+
const stops = changes !== undefined ? `${changes} time${changes === 1 ? "" : "s"}` : "at each colour change";
|
|
94
|
+
if (!feed.known)
|
|
95
|
+
return { facts: { ...base, printer: "unknown" },
|
|
96
|
+
note: `This prints in ${colours} colours${changes !== undefined ? ` and changes filament ${changes} time${changes === 1 ? "" : "s"}` : ""}. Without an AMS, the printer stops ${changes !== undefined ? "for each change" : "at each colour change"} for you to swap filament: print it in one colour, or each colour as its own part.` };
|
|
97
|
+
if (feed.ams_slots === 0 && feed.external > 1 && colours <= feed.external)
|
|
98
|
+
return { facts: { ...base, printer: "unknown", feeds, source: `${feed.source}; its ${feed.external} external spools feed ${colours} colours only with each colour on its own nozzle` },
|
|
99
|
+
note: `This prints in ${colours} colours. Without an AMS it needs each colour on its own nozzle, or it stops ${stops} for you to swap filament.` };
|
|
100
|
+
// A dual-nozzle printer can also feed its other nozzle's external spool beside its AMS trays, depending on the plate's
|
|
101
|
+
// nozzle bindings, which aren't read here (Codex review, #170): those colours are flagged, not refused.
|
|
102
|
+
if (feed.ams_slots > 0 && feed.external > 1 && colours > feeds && colours <= feeds + feed.external - 1)
|
|
103
|
+
return { facts: { ...base, printer: "unknown", feeds: feeds + feed.external - 1, source: `${feed.source}; the other nozzle's external spool can feed one more colour, depending on the plate's nozzle bindings` },
|
|
104
|
+
note: `This prints in ${colours} colours, one more than the AMS holds. It needs that colour on the other nozzle's external spool, or it stops for you to swap filament.` };
|
|
105
|
+
if (feeds >= colours) return { facts: { ...base, printer: "feeds-all", feeds } };
|
|
106
|
+
const plain = feed.ams_slots === 0
|
|
107
|
+
? `This prints in ${colours} colours. Your printer has no AMS, so it would stop ${stops} for you to change filament. Print it in one colour instead, or print each colour as its own part.`
|
|
108
|
+
: `This prints in ${colours} colours, but your printer can hold ${feeds} filaments, so it would stop for you to change filament by hand. Print it in fewer colours, or print each colour as its own part.`;
|
|
109
|
+
if (manual)
|
|
110
|
+
return { facts: { ...base, printer: "too-few-feeds", feeds, manual: true },
|
|
111
|
+
note: feed.ams_slots === 0 ? `Your printer has no AMS, so this print stops ${stops} for you to change filament.` : `This print stops for you to change filament by hand.` };
|
|
112
|
+
const facts = { ...base, printer: "too-few-feeds" as const, feeds };
|
|
113
|
+
const refusal = new FilamentSlotsError(colours, feeds, { plain, changes });
|
|
114
|
+
refusal.feed = facts;
|
|
115
|
+
return { facts, refusal };
|
|
116
|
+
}
|