model
Compile a .pwmodel text recipe of geometry operations into one Static Mesh asset, so the shape stays re-editable source.
What it’s for
This namespace compiles a .pwmodel text file — a short recipe of geometry
operations — into exactly one Static Mesh asset. You describe the shape once, in a file you
commit next to the asset, and the mesh is rebuilt from it. One source file, one mesh.
Reach for it when the shape needs to stay editable. A mesh cannot be decompiled back into the
operations that made it: triangles do not remember “box minus sphere”. With a
.pwmodel beside the asset, widening the third of eight holes is a one-line edit and a
recompile, and the change is a readable diff in git. Use the geometry namespace
instead when you want to push a placed mesh around in the level and do not need durable source.
The loop is: model.describe_ops to see the operation vocabulary,
model.validate to check a draft as an inline string (it creates nothing), then
model.compile on the written file. Diagnostics are structured — severity, line,
column, a stable code — so your assistant can fix its own source. Every generated asset is
stamped with the source it came from, and a compile refuses to discard hand edits it did not make
unless you pass overwrite.
pwmodel 0 format carries no compatibility promise yet, and the
GeometryScripting engine plugin must be enabled.
Examples
Compile a crate from source
The smallest valid document is a version line and one part whose first operation makes geometry.
You: Make me a simple crate mesh from a source file.
Source/Models/SM_Crate.pwmodel:
pwmodel 0
part body {
box size=(80, 50, 40)
}
call("model.compile", {filePath:"Source/Models/SM_Crate.pwmodel",
outputPath:"/Game/Models/SM_Crate"})
→ {ok:true, assetPath:"/Game/Models/SM_Crate", parts:1}
Done. SM_Crate is built from Source/Models/SM_Crate.pwmodel; edit that file and recompile to change it.
Check a draft before writing a file
model.validate takes the source as a string and creates no asset, so the assistant can
iterate on the recipe until the diagnostics are clean, then write the file once.
You: Put a scooped dent in the end of that crate before you commit it.
call("model.validate", {text:"pwmodel 0\n\npart body {\n box size=(80, 50, 40)\n
subtract {\n sphere radius=18 at=(25, 0, 0)\n }\n}"})
→ {ok:true, parts:["body"], diagnostics:[]}
Parses clean. Writing that to Source/Models/SM_Crate.pwmodel and recompiling.