Parametric Adapter
Gemma 4 31b · full
Reviews & generation details
Reviews
No human review yet. Unreviewed does not mean unsuccessful.
Generation context
Imported historical artifact. Its exact original instructions and lineage are not known.
Generation prompt · exact text unavailable
See the current prompt for reference. It may differ from the instructions used to generate this artifact.
Inspect original source 6,997 bytes · SHA-256 5f0fb91ae943
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OpenSCAD Adapter Generator (GHT to NPT)</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
body { background-color: #1a1a1a; color: #e0e0e0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
.code-block { background-color: #2d2d2d; border-radius: 8px; padding: 1rem; font-family: 'Fira Code', 'Courier New', Courier, monospace; overflow-x: auto; border: 1px solid #444; }
.accent-color { color: #4ade80; }
.button-primary { background-color: #4ade80; color: #1a1a1a; transition: all 0.2s; }
.button-primary:hover { background-color: #22c55e; transform: translateY(-1px); }
</style>
</head>
<body class="p-8">
<div class="max-w-4xl mx-auto">
<header class="mb-8 text-center">
<h1 class="text-4xl font-bold mb-2">OpenSCAD Thread Adapter</h1>
<p class="text-gray-400">3/4" GHT Female ↔ 1/2" NPT Male</p>
<p class="text-sm text-gray-500 mt-2 italic">Requires BOSL2 Library</p>
</header>
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
<!-- Controls -->
<div class="bg-gray-800 p-6 rounded-xl border border-gray-700 shadow-xl">
<h2 class="text-xl font-semibold mb-4 border-b border-gray-700 pb-2">Parameters</h2>
<div class="space-y-4">
<div>
<label class="block text-sm mb-1">Wall Thickness (mm)</label>
<input type="number" id="wallThickness" value="3" step="0.5" class="w-full bg-gray-900 border border-gray-600 rounded px-2 py-1 outline-none focus:border-green-400">
</div>
<div>
<label class="block text-sm mb-1">Hex Nut Size (mm)</label>
<input type="number" id="hexSize" value="25" step="1" class="w-full bg-gray-900 border border-gray-600 rounded px-2 py-1 outline-none focus:border-green-400">
</div>
<div>
<label class="block text-sm mb-1">Transition Height (mm)</label>
<input type="number" id="transHeight" value="5" step="0.5" class="w-full bg-gray-900 border border-gray-600 rounded px-2 py-1 outline-none focus:border-green-400">
</div>
<div class="pt-4">
<button onclick="generateCode()" class="w-full button-primary font-bold py-2 rounded shadow-lg">Update Code</button>
</div>
</div>
<div class="mt-8 text-xs text-gray-500 leading-relaxed">
<p class="font-bold mb-1">Notes:</p>
<ul class="list-disc pl-4 space-y-1">
<li>GHT (Garden Hose Thread) follows NH/ANSI standards.</li>
<li>NPT (National Pipe Thread) is tapered.</li>
<li>BOSL2's <code>threaded_nut</code> and <code>threaded_bolt</code> are used for precision.</li>
</ul>
</div>
</div>
<!-- Code Display -->
<div class="md:col-span-2 flex flex-col">
<div class="flex justify-between items-center mb-2">
<span class="text-sm font-medium text-gray-400">adapter.scad</span>
<button onclick="copyCode()" class="text-xs bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded transition">Copy Code</button>
</div>
<div id="codeOutput" class="code-block text-sm leading-relaxed flex-grow whitespace-pre"></div>
</div>
</div>
<div class="mt-12 p-6 bg-blue-900/20 border border-blue-800/50 rounded-xl">
<h3 class="text-blue-400 font-bold mb-2">How to use:</h3>
<ol class="list-decimal pl-5 space-y-2 text-gray-300 text-sm">
<li>Install the <a href="https://github.com/BOSL2/BOSL2" target="_blank" class="underline text-blue-300">BOSL2 library</a> in your OpenSCAD library folder.</li>
<li>Copy the generated code above.</li>
<li>Paste into OpenSCAD and press <kbd class="bg-gray-700 px-1 rounded text-xs">F5</kbd> to preview or <kbd class="bg-gray-700 px-1 rounded text-xs">F6</kbd> to render.</li>
<li>Export as STL for 3D printing.</li>
</ol>
</div>
</div>
<script>
function generateCode() {
const wall = document.getElementById('wallThickness').value;
const hex = document.getElementById('hexSize').value;
const trans = document.getElementById('transHeight').value;
const code = `include <BOSL2/std.scad>
include <BOSL2/threading.scad>
/*
* Adapter: 3/4" GHT Female to 1/2" NPT Male
* Generated via Interactive Tool
*/
// Parameters
wall_thickness = ${wall};
hex_size = ${hex};
transition_h = ${trans};
// Thread Definitions
// GHT 3/4" is roughly 1.05" OD, 11.5 TPI (Standard Garden Hose)
ght_34_female = [
diameter=26.67, // Approx 3/4" GHT Major Dia
pitch=2.18, // 11.5 TPI approx
length=15,
internal=true
];
// NPT 1/2" is tapered
npt_12_male = [
diameter=21.3, // Approx 1/2" NPT Major Dia
pitch=1.81, // 14 TPI approx
length=12,
internal=false,
taper=1.5 // NPT standard taper is approx 1.5 deg per side
];
module adapter() {
union() {
// --- GHT Female Section ---
diff() {
// Outer Body (Hex)
cylinder(h=15, d=hex_size, $fn=6);
// The Threaded Hole
threaded_nut(ght_34_female);
// Through Hole
cylinder(h=16, d=16, anchor=BOTTOM);
}
// --- Transition Section ---
translate([0,0,15])
cylinder(h=transition_h, d=hex_size * 0.8, $fn=64);
// --- NPT Male Section ---
translate([0,0,15 + transition_h])
threaded_bolt(npt_12_male, anchor=BOTTOM);
}
}
// Final Render
adapter();
`;
document.getElementById('codeOutput').textContent = code;
}
async function copyCode() {
const code = document.getElementById('codeOutput').textContent;
await navigator.clipboard.writeText(code);
const btn = event.target;
const oldText = btn.textContent;
btn.textContent = 'Copied!';
setTimeout(() => btn.textContent = oldText, 2000);
}
// Initial generation
generateCode();
</script>
</body>
</html>
<!-- agent-meta {"model":"gemma-4-31b","provider":"cerebras","persona":"full","sessionId":"a222768c-6d3e-402d-840e-7e0912585d0e","tokensIn":7672,"tokensOut":2427,"tokensTotal":10099,"turns":2,"toolCalls":1,"failedToolCalls":0,"timestamp":"2026-07-14T16:26:12.283Z"} -->