Translate first Geometry Script corpus graph

This commit is contained in:
Meta Vens 2026-05-04 13:21:30 +01:00
commit 58d5515763
8 changed files with 416 additions and 11 deletions

2
.gitignore vendored
View file

@ -5,5 +5,7 @@ node_modules/
state/scratch-compaction-*.md
experiments/renders/
experiments/blender-cache/
experiments/source-blends/
experiments/inspection/
*.blend1
*.blend2

View file

@ -96,6 +96,13 @@ licensed, and contains several bounded `.blend` examples. The first useful
translation is a tiny graph from `cartesian.blend` or `piechart.blend`, chosen
after node group inspection.
First completed translation entry:
- `docs/research/translations/shriinivas-cartesian-helper.md`
- Source group: `NodeGroup.001` from `cartesian.blend`
- Geometry Script recreation:
`examples/geometry_script/shriinivas_cartesian_helper.py`
## Extraction Workflow
1. Download one source `.blend` into an ignored experiment folder.
@ -113,6 +120,10 @@ after node group inspection.
## Known Tooling Need
We need a small Blender inspection script that can summarize node groups from a
`.blend` file into JSON. Without that, every example becomes manual archaeology
with better branding.
`tools/inspect_blend_node_groups.py` can summarize geometry node groups from an
opened `.blend` file into JSON. It records group interfaces, nodes, simple node
properties, sockets, links, and modifier users.
Generated node groups must be referenced by an object/modifier or marked with
`use_fake_user = True` before saving a `.blend`; otherwise Blender discards the
orphaned group on save. Very normal behavior, if your filing cabinet hates you.

View file

@ -0,0 +1,134 @@
# Translation: Shriinivas Cartesian Helper
## Source
- Repository: https://github.com/Shriinivas/geometrynodes
- Source file: `cartesian.blend`
- Local ignored copy:
`experiments/source-blends/shriinivas-cartesian.blend`
- Source node group: `NodeGroup.001`
- License: MIT, per source repository.
## Why This Graph
This was the smallest geometry node group in `cartesian.blend` after inspection.
It is a useful first translation because it combines:
- group inputs and multiple outputs
- a generated curve primitive
- curve resampling
- field-driven position reads
- scalar math
- vector recomposition
It does not include materials, object modifiers, or final scene polish. That is
good. First learn the tendon before drawing the whole hand.
## Source Inspection
Inspected with:
```powershell
& 'C:\Program Files (x86)\Steam\steamapps\common\Blender\blender.exe' --background '.\experiments\source-blends\shriinivas-cartesian.blend' --python '.\tools\inspect_blend_node_groups.py' -- --json '.\experiments\inspection\shriinivas-cartesian-node-groups.json'
```
Source group summary:
- Node group: `NodeGroup.001`
- Nodes: 15
- Links: 20
- Inputs: `Count`, `Start`, `End`, `r`, `Value`
- Outputs: `Curve`, `Vector`
- Node types:
- `GeometryNodeCurvePrimitiveLine`
- `GeometryNodeInputPosition`
- `GeometryNodeResampleCurve`
- `NodeGroupInput`
- `NodeGroupOutput`
- `NodeReroute`
- `ShaderNodeCombineXYZ`
- `ShaderNodeMath`
- `ShaderNodeSeparateXYZ`
## Plain-Language Graph Map
The group builds a straight curve from `Start` to `End`, then resamples it to
`Count` points. That output is the `Curve`.
Separately, it reads the current `Position` field and splits it into X, Y, and
Z. It keeps X and Z as-is. For Y, it computes:
```text
sqrt(r^2 - x^2) * Value
```
Then it combines:
```text
(x, sqrt(r^2 - x^2) * Value, z)
```
That output is the `Vector`.
The group is a helper for bending or lifting a Cartesian curve into a circular
arc-like profile. It does not move geometry by itself; it emits the curve and
the vector field that another graph can feed into `Set Position`.
## Geometry Script Translation
Script:
```text
examples/geometry_script/shriinivas_cartesian_helper.py
```
The translation intentionally omits source reroute nodes. Reroutes clarify the
visual editor layout but do not change graph semantics.
One small compatibility adjustment is made after generation: the auto-created
Geometry Script input socket `R` is renamed to `r` to match the source group.
## Verification
Smoke-tested with Blender 5.1.1:
```powershell
& 'C:\Program Files (x86)\Steam\steamapps\common\Blender\blender.exe' --background --python '.\examples\geometry_script\shriinivas_cartesian_helper.py'
```
Result:
```text
VG_CARTESIAN_HELPER True 12 19
```
Generated node types:
- `GeometryNodeCurvePrimitiveLine`
- `GeometryNodeInputPosition`
- `GeometryNodeResampleCurve`
- `NodeGroupInput`
- `NodeGroupOutput`
- `ShaderNodeCombineXYZ`
- `ShaderNodeMath`
- `ShaderNodeSeparateXYZ`
Saved-and-reinspected generated `.blend`:
```text
VG Cartesian Helper: nodes=12 links=19
```
The generated group has fewer nodes than the source because it omits three
`NodeReroute` layout nodes and one reroute link. The computational nodes match
the source mechanism.
## Lessons
- The local generated Geometry Script docs should be checked before writing each
node call. Function signatures and result-object shapes matter.
- Geometry Script is good at semantic graph construction, but it will not
preserve visual-editor layout details such as reroutes unless we explicitly
add them.
- Generated node groups need `use_fake_user = True` or a real modifier/object
user before saving, or Blender will discard them as orphan data.

View file

@ -0,0 +1,72 @@
"""Geometry Script recreation of a helper group from Shriinivas/cartesian.blend.
Source:
https://github.com/Shriinivas/geometrynodes/blob/main/cartesian.blend
The source group is named ``NodeGroup.001``. It creates a resampled curve line
and a vector field where Y is lifted by ``sqrt(r^2 - x^2) * value`` while X and
Z are preserved from the current position.
"""
import addon_utils
addon_utils.enable("geometry-script-main", default_set=False, persistent=False)
from geometry_script import * # noqa: F403 - Geometry Script exposes node functions as DSL globals.
@tree("VG Cartesian Helper")
def vg_cartesian_helper(
count: Int = 10,
start: Vector = (0.0, 0.0, 0.0),
end: Vector = (0.0, 0.0, 1.0),
r: Float = 1.0,
value: Float = 1.0,
):
curve = curve_line(mode=CurveLine.Mode.POINTS, start=start, end=end)
sampled_curve = curve.resample_curve(count=count)
position_parts = separate_xyz(vector=position())
radius_squared = math(operation=Math.Operation.POWER, value=(r, 2.0))
x_squared = math(operation=Math.Operation.POWER, value=(position_parts.x, 2.0))
y = math(
operation=Math.Operation.MULTIPLY,
value=(
math(
operation=Math.Operation.SQRT,
value=math(operation=Math.Operation.SUBTRACT, value=(radius_squared, x_squared)),
),
value,
),
)
vector = combine_xyz(x=position_parts.x, y=y, z=position_parts.z)
return {"Curve": sampled_curve, "Vector": vector}
def _finalize_group():
import bpy
group = bpy.data.node_groups.get("VG Cartesian Helper")
if not group:
return None
group.use_fake_user = True
if hasattr(group, "interface"):
for item in group.interface.items_tree:
if item.item_type == "SOCKET" and item.in_out == "INPUT" and item.name == "R":
item.name = "r"
return group
_finalize_group()
if __name__ == "__main__":
group = _finalize_group()
print(
"VG_CARTESIAN_HELPER",
bool(group),
len(group.nodes) if group else -1,
len(group.links) if group else -1,
sorted(node.bl_idname for node in group.nodes) if group else [],
)

View file

@ -23,12 +23,16 @@ git log --oneline -5
## Current State
VibeGeometry is an initial scaffold. It has persistence machinery, project
orientation docs, helper tools, and an initial Geometry Nodes translation corpus
note, but no Blender builder library or artifact schemas yet.
orientation docs, helper tools, and the first Geometry Nodes translation corpus
entry, but no Blender builder library or artifact schemas yet.
The current next action is to build the first Geometry Nodes translation corpus
entry by inspecting a small public `.blend` node group, mapping its graph in
prose, and recreating it with Geometry Script.
The first completed translation is
`docs/research/translations/shriinivas-cartesian-helper.md`, backed by
`examples/geometry_script/shriinivas_cartesian_helper.py`.
The current next action is to translate the source `Geometry Nodes Line` group
from `cartesian.blend` using the completed helper as the first reusable
subgraph, then render or visually inspect the generated line output.
## Important Invariants

View file

@ -2,3 +2,4 @@
{"ts": "2026-05-04T11:52:15+00:00", "type": "research", "status": "ok", "note": "Geometry Script add-on is installed under Blender 5.1 and imports headlessly. A trivial cube node group built successfully in Blender 5.1.1; the documented grid().mesh_to_points() chain failed with NoneType callable, so Geometry Script should be treated as promising but each idiom must be smoke-tested against the installed Blender/add-on pair."}
{"ts": "2026-05-04T11:55:00+00:00", "type": "research", "status": "ok", "note": "Local Geometry Script 5.1 generated docs are the authoritative node-signature source for this workspace. The prior grid().mesh_to_points() probe failed because grid() returns a result object with mesh and uv_map; the valid chain is grid(...).mesh.mesh_to_points(...)."}
{"ts": "2026-05-04T12:11:47+00:00", "type": "research", "status": "accepted", "note": "Public Geometry Nodes learning material is mostly screenshots, videos, and downloadable .blend files. VibeGeometry should build durable Geometry Script knowledge by inspecting source .blend node groups, mapping one graph at a time in prose, then recreating and smoke-testing with local Geometry Script 5.1 signatures."}
{"ts": "2026-05-04T12:21:06+00:00", "type": "implementation", "status": "accepted", "note": "Completed first Geometry Nodes translation corpus entry: inspected Shriinivas/cartesian.blend NodeGroup.001, mapped its curve/vector field flow, recreated it as examples/geometry_script/shriinivas_cartesian_helper.py, and smoke-tested generation/save/reinspection in Blender 5.1.1. Generated node groups need fake users or real users before saving."}

View file

@ -47,7 +47,8 @@ live_architecture:
active_subgoals:
- Keep the pipeline legible from visual target to graph strategy to Python builder to render review.
- Define artifact schemas before generating many example scenes.
- Build a graded Geometry Nodes translation corpus before hardening schemas or builder abstractions.
- Define artifact schemas after enough translated examples expose the real contract pressure.
- Build a minimal Blender runner only after the scene brief and graph manifest contracts are clear.
- Collect Blender 5.0+ geometry-node API and best-practice evidence before hardening graph builders.
- Preserve one-hypothesis iteration when visual results miss the target.
@ -62,6 +63,7 @@ current_artifacts:
tools:
- tools/vibegeometry_state.py
- tools/vibegeometry_prepare_compaction.py
- tools/inspect_blend_node_groups.py
pending_contracts:
- schemas/scene-brief.schema.json
- schemas/node-graph-manifest.schema.json
@ -76,5 +78,5 @@ data_flow:
- If state grows faster than understanding, cut it back.
current_status:
summary: VibeGeometry has an initial Epiphany-style persistence scaffold adapted for Blender geometry-node scene generation, with project-neutral state, handoff, architecture notes, and helper tools.
next_action: Build the first Geometry Nodes translation corpus entry by inspecting a small public `.blend` node group, mapping its graph in prose, and recreating it with Geometry Script.
summary: VibeGeometry has an initial persistence scaffold plus the first Geometry Nodes translation corpus entry: a small helper group from Shriinivas/cartesian.blend recreated with Geometry Script and smoke-tested in Blender 5.1.1.
next_action: Translate the source `Geometry Nodes Line` group from `cartesian.blend` using the completed helper as the first reusable subgraph, then render or visually inspect the generated line output.

View file

@ -0,0 +1,179 @@
"""Inspect Geometry Nodes node groups in the currently opened Blender file.
Run with Blender:
blender --background source.blend --python tools/inspect_blend_node_groups.py -- --json out.json
"""
from __future__ import annotations
import argparse
import json
import sys
from typing import Any
import bpy
def _jsonable(value: Any) -> Any:
if value is None or isinstance(value, (str, int, float, bool)):
return value
if hasattr(value, "to_tuple"):
return list(value.to_tuple())
if isinstance(value, (list, tuple)):
return [_jsonable(item) for item in value]
return repr(value)
def _socket_summary(socket: Any) -> dict[str, Any]:
summary = {
"name": getattr(socket, "name", ""),
"identifier": getattr(socket, "identifier", ""),
"type": getattr(socket, "type", ""),
"bl_socket_idname": getattr(socket, "bl_socket_idname", ""),
"enabled": getattr(socket, "enabled", None),
"is_linked": getattr(socket, "is_linked", None),
"is_multi_input": getattr(socket, "is_multi_input", None),
}
if hasattr(socket, "default_value"):
try:
summary["default_value"] = _jsonable(socket.default_value)
except Exception as exc: # pragma: no cover - Blender API guardrail
summary["default_value_error"] = str(exc)
return summary
def _interface_item_summary(item: Any) -> dict[str, Any]:
summary = {
"name": getattr(item, "name", ""),
"item_type": getattr(item, "item_type", ""),
"in_out": getattr(item, "in_out", ""),
"socket_type": getattr(item, "socket_type", ""),
"identifier": getattr(item, "identifier", ""),
"description": getattr(item, "description", ""),
}
for attr in ("default_value", "min_value", "max_value", "hide_value", "hide_in_modifier"):
if hasattr(item, attr):
try:
summary[attr] = _jsonable(getattr(item, attr))
except Exception as exc: # pragma: no cover - Blender API guardrail
summary[f"{attr}_error"] = str(exc)
return summary
def _node_summary(node: Any) -> dict[str, Any]:
ignored_props = {
"rna_type",
"name",
"label",
"location",
"width",
"height",
"dimensions",
"inputs",
"outputs",
"internal_links",
"parent",
"select",
"show_options",
"show_preview",
"show_texture",
"hide",
"mute",
"use_custom_color",
"warning_propagation",
}
properties: dict[str, Any] = {}
for prop in node.bl_rna.properties:
if prop.identifier in ignored_props or prop.is_readonly:
continue
if prop.identifier.startswith("bl_"):
continue
try:
value = getattr(node, prop.identifier)
except Exception:
continue
if value is None or isinstance(value, (str, int, float, bool)):
properties[prop.identifier] = value
return {
"name": node.name,
"label": node.label,
"bl_idname": node.bl_idname,
"type": node.type,
"properties": properties,
"location": _jsonable(node.location),
"inputs": [_socket_summary(socket) for socket in node.inputs],
"outputs": [_socket_summary(socket) for socket in node.outputs],
}
def _link_summary(link: Any) -> dict[str, str]:
return {
"from_node": link.from_node.name,
"from_socket": link.from_socket.name,
"from_socket_identifier": getattr(link.from_socket, "identifier", ""),
"to_node": link.to_node.name,
"to_socket": link.to_socket.name,
"to_socket_identifier": getattr(link.to_socket, "identifier", ""),
}
def _modifier_users() -> list[dict[str, str]]:
users: list[dict[str, str]] = []
for obj in bpy.data.objects:
for modifier in obj.modifiers:
if modifier.type == "NODES" and getattr(modifier, "node_group", None):
users.append(
{
"object": obj.name,
"modifier": modifier.name,
"node_group": modifier.node_group.name,
}
)
return users
def inspect_file() -> dict[str, Any]:
node_groups = []
for group in bpy.data.node_groups:
if group.bl_idname != "GeometryNodeTree":
continue
interface_items = []
if hasattr(group, "interface") and hasattr(group.interface, "items_tree"):
interface_items = [_interface_item_summary(item) for item in group.interface.items_tree]
node_groups.append(
{
"name": group.name,
"bl_idname": group.bl_idname,
"is_modifier": getattr(group, "is_modifier", None),
"is_tool": getattr(group, "is_tool", None),
"interface": interface_items,
"node_count": len(group.nodes),
"link_count": len(group.links),
"nodes": [_node_summary(node) for node in group.nodes],
"links": [_link_summary(link) for link in group.links],
}
)
return {
"blend_file": bpy.data.filepath,
"blender_version": bpy.app.version_string,
"node_groups": sorted(node_groups, key=lambda item: item["name"].lower()),
"modifier_users": _modifier_users(),
}
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--json", required=True, help="Path for the inspection JSON output.")
args = parser.parse_args(sys.argv[sys.argv.index("--") + 1 :] if "--" in sys.argv else [])
data = inspect_file()
with open(args.json, "w", encoding="utf-8") as handle:
json.dump(data, handle, indent=2)
handle.write("\n")
print(f"Inspected {len(data['node_groups'])} geometry node groups -> {args.json}")
return 0
if __name__ == "__main__":
raise SystemExit(main())