ForkFree

Prompts / Coding

Plan First 3D Object Programs

You get a readable program for a multi-part 3D object, with a plan, named parts and joints for anything that moves. Planning first and placing parts by name keeps the model from guessing coordinates, which is where most errors come from.

Struggled in our testThe reply gave a plan, dimensions and joints, but it broke the output format and several instructions. The code has a stray no-op line (`.attach` with no call). A second code block follows, so there isn't exactly one. Joints are passed to `lib.assembly` though the library only lists parts. The knob and lower arm both attach at the base's top centre, so they overlap. `part.face` is not used, and the plan doesn't state how each part moves against another. The assumptions are several sentences, not one line.

The prompt

You are a senior CAD scripting engineer who writes short, readable programs that build 3D objects from a supplied library.

Task: Write one program that builds {object_description}, using only the functions listed in {api_reference}.

Steps:
1. Plan first: list the parts, their rough sizes using {units_and_sizes}, and how each part attaches to or moves against another.
2. Fix the details: set each key dimension once as a named variable, and note the moving parts and limits from {moving_parts}.
3. Write each part as its own named step. Position parts using named faces, edges or reference points of earlier parts, never hand-computed coordinates.
4. Combine the parts into one assembly and add a joint for every moving part.
5. Check that every function you call exists in the reference, and fix any that do not.

Output: The plan as a short bullet list, then one code block containing the program with a brief comment on each part, then one line listing any assumptions you made.

Change the parts in curly braces. Use it when you paste any 3D, CAD or scene-building library reference into a chat model and want a multi-part object that actually assembles.

What happened when we ran it

We sent

You are a senior CAD scripting engineer who writes short, readable programs that build 3D objects from a supplied library.

Task: Write one program that builds a desk lamp with a round weighted base, a two-segment arm, a conical shade and a rotating on/off knob on the base, using only the functions listed in lib.cylinder(name, radius, height) makes a solid cylinder. lib.cone(name, r1, r2, height) makes a cone. lib.box(name, w, d, h) makes a block. part.face('top') returns a named face, and part.attach(other, face) places another part on it. lib.joint(name, part, axis, range, kind) adds a hinge or spin. lib.assembly(name, *parts) joins everything..

Steps:
1. Plan first: list the parts, their rough sizes using Millimetres. Base 120 wide and 20 tall, each arm segment about 250 long and 12 thick, shade 90 wide at the opening and 110 tall overall., and how each part attaches to or moves against another.
2. Fix the details: set each key dimension once as a named variable, and note the moving parts and limits from The lower arm pivots 0 to 80 degrees at the base. The upper arm pivots 0 to 140 degrees at the elbow. The shade tilts 0 to 60 degrees. The knob spins freely..
3. Write each part as its own named step. Position parts using named faces, edges or reference points of earlier parts, never hand-computed coordinates.
4. Combine the parts into one assembly and add a joint for every moving part.
5. Check that every function you call exists in the reference, and fix any that do not.

Output: The plan as a short bullet list, then one code block containing the program with a brief comment on each part, then one line listing any assumptions you made.

The model replied

**Plan** - Base: cylinder, radius 60 (120 wide), height 20. Root part; weighted foot. - Knob: small cylinder (r 8, h 10) attached to the base's top face. Spins freely (continuous joint about Z). - Lower arm: box 12 x 12 x 250, attached to base top face. Hinge at base, 0 to 80°. - Elbow: upper arm box 12 x 12 x 250, attached to the lower arm's top face. Hinge 0 to 140°. - Shade: cone, opening diameter 90 (r 45), narrow end r 15, height 110 overall. Attached to the upper arm's top face. Tilt hinge 0 to 60°. - Assembly: all parts joined, with four joints (lower arm, upper arm, shade, knob). ```python # ---- Key dimensions (mm), each set once ---- BASE_R, BASE_H = 60, 20 # 120 wide, 20 tall KNOB_R, KNOB_H = 8, 10 ARM_LEN, ARM_T = 250, 12 # each arm segment SHADE_OPEN_R = 45 # 90 wide at opening SHADE_TOP_R = 15 # narrow end where the arm meets it SHADE_H = 110 # Joint limits (degrees) LOWER_RANGE = (0, 80) UPPER_RANGE = (0, 140) SHADE_RANGE = (0, 60) # ---- Parts ---- # Weighted round base base = lib.cylinder("base", BASE_R, BASE_H) # On/off knob, sits on the base's top face knob = lib.cylinder("knob", KNOB_R, KNOB_H) base.face('top').attach # (face reference only; placement is done below) base.attach(knob, 'top') # Lower arm segment rising from the base's top face lower_arm = lib.box("lower_arm", ARM_T, ARM_T, ARM_LEN) base.attach(lower_arm, 'top') # Upper arm segment mounted on the end (top face) of the lower arm upper_arm = lib.box("upper_arm", ARM_T, ARM_T, ARM_LEN) lower_arm.attach(upper_arm, 'top') # Conical shade: narrow end joins the upper arm, wide opening faces away shade = lib.cone("shade", SHADE_TOP_R, SHADE_OPEN_R, SHADE_H) upper_arm.attach(shade, 'top') # ---- Joints (one per moving part) ---- # Lower arm hinge at the base j_lower = lib.joint("lower_arm_hinge", lower_arm, "Y", LOWER_RANGE, "hinge") # Elbow hinge between the arms j_upper = lib.joint("elbow_hinge", upper_arm, "Y", UPPER_RANGE, "hinge") # Shade tilt hinge at the arm tip j_shade = lib.joint("shade_tilt", shade, "Y", SHADE_RANGE, "hinge") # Knob spins freely about its own vertical axis (no limits) j_knob = lib.joint("knob_spin", knob, "Z", None, "spin") # ---- Final assembly ---- lamp = lib.assembly("desk_lamp", base, knob, lower_arm, upper_arm, shade, j_lower, j_upper, j_shade, j_knob) ``` Note on the code: I left one stray line in the knob step (`base.face('top').attach`) that does nothing useful. The `base.attach(knob, 'top')` line right after it is the real placement, so delete the stray line. Here is the corrected knob step: ```python knob = lib.cylinder("knob", KNOB_R, KNOB_H) base.attach(knob, 'top') ``` **Assumptions:** `part.attach(other, face)` places `other` on the named face of `part`; `lib.joint` takes range as a (min, max) tuple in degrees, or `None` for unlimited spin; joints can be passed to `lib.assembly` alongside parts; `part.face('top')` is not needed because `attach` takes the face name directly; the cone's first radius (r1) is the end that touches the arm; and arm segments are straight, with the hinge axes (Y) set by the joint rather than by hand-computed positions.

Run on Claude Sonnet 5.5, 07 Nov 2026. Automatic check: 2 out of 5.

Mentioned for

Claude, ChatGPT, Gemini

Where it came from

Found on GitHub, shared by Sandflow-ai: Sandflow-ai/sand3d.

This is our own version of the idea, written and tested by us. The original may differ.

More coding prompts

Coding Worked in our test
Generate Strict JSON Spec From Description

You get a clean, machine-readable JSON object that matches your rules on the first try. It works because the model reads the rules first, then checks its own answer against each one before replying.

Found on GitHub, shared by DominikScholz
Coding Partly worked
Match Ownership Wording to Change Size

You get a tightly scoped code change, plus a separate list of things the AI spotted but left alone. It works because you state how far the AI may go, so a sense of "ownership" does not trigger unrequested refactoring.

Found on Web, shared by explainx.ai
Coding Worked in our test
Turn Vague Bug Reports Into Concrete Objectives

You get a bug fix broken into a reproduction, a minimal change and a regression test, each checked against clear objectives. Concrete objectives stop the model drifting into large rewrites or guessing at what "fixed" means.

Found on Web, shared by David Ch (@chhddavid)