Files
workinf_Blender_Wasm/tools/web/generate-curves-fixture.py
mes123456 10640aeb3c
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Govern task context and advance execution pointer
2026-08-20 06:02:43 -04:00

30 lines
1.3 KiB
Python

#!/usr/bin/env python3
import sys
import bpy
def main(output):
bpy.ops.wm.read_factory_settings(use_empty=True)
legacy = bpy.data.curves.new("WebGapCurvesSeed", "CURVE")
legacy.dimensions = "3D"
spline = legacy.splines.new("BEZIER")
spline.bezier_points.add(3)
for point, co in zip(spline.bezier_points, ((-1.5, 0, 0), (-0.5, 0.3, 0.5), (0.5, 0, 0), (1.5, 0.3, 0.5))):
point.co = co
point.handle_left_type = "AUTO"
point.handle_right_type = "AUTO"
object_ = bpy.data.objects.new("WebGapCurvesObject", legacy)
bpy.context.collection.objects.link(object_)
bpy.context.view_layer.objects.active = object_
object_.select_set(True)
bpy.ops.object.convert(target="CURVES")
if legacy != object_.data: bpy.data.curves.remove(legacy, do_unlink=True)
object_.data.name = "WebGapCurves"
radius = object_.data.attributes.get("radius") or object_.data.attributes.new("radius", "FLOAT", "POINT")
for index, item in enumerate(radius.data): item.value = 0.03 + index * 0.005
bpy.ops.wm.save_as_mainfile(filepath=output, compress=True)
if __name__ == "__main__":
args = sys.argv[sys.argv.index("--") + 1:]
if len(args) != 1: raise SystemExit("usage: blender -b --python generate-curves-fixture.py -- OUTPUT")
main(args[0])