dymokomi/luced-3d
Source of release 0.11.6
0.11.6 / tests / editor / cad_parity_tests.luc
## The Fusion parity round's Extrude and Revolve options, each a node in
## the chain checked by its body's volume: Thin extrude (Side 1, Side 2,
## Center), a body face extruded as the profile (Extrude face, and picked in
## Pick profiles), Start: Object (a face picked by Pick start object), a
## start offset with To object and All, To object's Extend (To body,
## Through body), Objects To Cut (Pick bodies, Auto-select), Cut acting on
## each body apart, and Revolve To a face (Pick object).
from app import Luce3D
from workspace import Workspace
from luce_3d.graphics import Vector3
from luce_cad.cad_geometry import CadGeometry
from luce_cad.modeling import CadModeling
import tool_picks
import node_commands
import selection_commands
import sketch_commands
import tool_prompts
import cad_features
import cad_blends
import extrude_inputs
from luce_std import math
from luce_ui.ui import Event
from luce_window.input import EventKind
from luce_cad.sketch import CadSketch
from view_projection import project
from sketch_support import render
from edit_types import smart_level
pub func cad_parity_tests() -> unit!:
thin_extrude()
face_profiles()
starts_and_extends()
objects_to_cut()
revolve_to()
blend_options()
shown_sketch()
print("PASS CAD parity: Thin extrude on Side 1, Side 2 and Center, a closed rectangle and an open line, Fusion's own bounds and volumes; Fillet's Tangency weight (1 the plain fillet, 2 more of the corner, G1 and G2); a face extruded as its own profile (Extrude face, Pick profiles); Start: Object from a picked face; a start offset with To object and All; Extend To body and Through body; Objects To Cut picked and Auto-select, Cut on each body apart; Revolve To a picked face, either way; Full round of a rib's picked top, a fillet by chord length and by a variable radius (G1 and G2), Setback corners, chamfer corners as Chamfer and Miter; a shown sketch's profile picked at the Faces level over the face beneath, extruded; its line picked at Smart as a Revolve's axis")
## The tessellated volume of every body of node `id`.
func volume(w: Workspace, id: int) -> float!:
let data = w.network.evaluate_data(id)
var total = 0.0
for at in 0..<CadGeometry.model_count(data.geometry):
let mesh = CadGeometry.model(data.geometry, at).tessellate(32)
for triangle in 0..<mesh.index_count() // 3:
let a = mesh.vertex(mesh.index(triangle * 3)).position
let b = mesh.vertex(mesh.index(triangle * 3 + 1)).position
let c = mesh.vertex(mesh.index(triangle * 3 + 2)).position
total += a.dot(b.cross(c)) / 6.0
return total
## Whether node `id`'s bodies have volume `expected` (to 0.3%).
func volume_is(w: Workspace, id: int, expected: float) -> bool!:
let got = volume(w, id)
if math.abs(got - expected) > math.abs(expected) * 0.003: print(f"volume {got}, expected {expected}")
return math.abs(got - expected) <= math.abs(expected) * 0.003
## The name of the face of node `id`'s first body facing `normal`.
func face_facing(w: Workspace, id: int, normal: Vector3) -> str!:
let model = CadGeometry.model(w.network.evaluate_data(id).geometry, 0)
for face in 0..<model.face_count():
let name = CadModeling.face_name_of(model, face)
let at = CadModeling.face_point(model, name)
if at.found and at.normal.dot(normal) > 0.999:
return name
return ""
## A new CAD node, entered.
func cad(w: Workspace) -> unit!:
node_commands.delete_selected(w)
node_commands.add_node(w, "CAD", 0.0, 0.0)
node_commands.enter_group(w, w.network.selected)
## Fusion 2705's own Thin Extrude (the probe of 2026-10-12): a 20 x 10
## rectangle from (0, 0) on XY, wall 2, 5 high: Side 1 inside it (20 x 10,
## 520), Side 2 outside (24 x 14, 680), Center half each way (22 x 12,
## 600); a line drawn from (0, 0) to (20, 0): Side 1 to its left (y 0 to
## 2), Side 2 its right (-2 to 0), Center -1 to 1.
func thin_extrude() -> unit!:
let w = Workspace()
cad(w)
node_commands.add_node(w, "Sketch", 0.0, 0.0)
let sketch = w.network.selected
node_commands.set_parameter(w, 0, 0.0)
node_commands.set_text(w, 0, sketch_commands.rectangle_text(10.0, 5.0, 20.0, 10.0))
node_commands.add_node(w, "Extrude", 0.0, 120.0)
let extrude = w.network.selected
node_commands.set_parameter(w, cad_features.distance_slot, 5.0)
node_commands.set_parameter(w, cad_features.type_slot, 1.0)
node_commands.set_parameter(w, cad_features.thickness_slot, 2.0)
let volumes = [520.0, 680.0, 600.0]
let lows = [0.0, -2.0, -1.0]
let highs = [(20.0, 10.0), (22.0, 12.0), (21.0, 11.0)]
for side in 0..<3:
node_commands.set_parameter(w, cad_features.wall_slot, float(side))
assert(volume_is(w, extrude, volumes[side]))
let (x, y) = highs[side]
assert(spans(w, extrude, lows[side], lows[side], x, y, 5.0))
# Back to a plain Extrude: the whole rectangle.
node_commands.set_parameter(w, cad_features.type_slot, 0.0)
assert(volume_is(w, extrude, 1000.0))
# The open line, drawn left to right.
let line = CadSketch.parse("")
_ = line.add_line(line.add_point(0.0, 0.0), line.add_point(20.0, 0.0))
node_commands.select_node(w, sketch)
node_commands.set_text(w, 0, line.text())
node_commands.select_node(w, extrude)
node_commands.set_parameter(w, cad_features.type_slot, 1.0)
let bottoms = [0.0, -2.0, -1.0]
for side in 0..<3:
node_commands.set_parameter(w, cad_features.wall_slot, float(side))
assert(spans(w, extrude, 0.0, bottoms[side], 20.0, bottoms[side] + 2.0, 5.0), f"open line, wall location {side}")
## Whether node `id`'s bodies span x `x0` to `x1`, y `y0` to `y1` and z 0
## to `height` (Fusion's bounding box).
func spans(w: Workspace, id: int, x0: float, y0: float, x1: float, y1: float, height: float) -> bool!:
let data = w.network.evaluate_data(id)
let bounds = CadGeometry.model(data.geometry, 0).tessellate(8).bounds()
let ok = math.abs(bounds.minimum.x - x0) < 1e-6 and math.abs(bounds.minimum.y - y0) < 1e-6 and math.abs(bounds.minimum.z) < 1e-6 and math.abs(bounds.maximum.x - x1) < 1e-6 and math.abs(bounds.maximum.y - y1) < 1e-6 and math.abs(bounds.maximum.z - height) < 1e-6
if not ok: print(f"spans ({bounds.minimum.x}, {bounds.minimum.y}, {bounds.minimum.z}) to ({bounds.maximum.x}, {bounds.maximum.y}, {bounds.maximum.z})")
return ok
## A box's top face selected at the Faces level and Extrude face: an
## Extrude of the face itself (no sketch), joined: 8000 + 400 × 10. Pick
## profiles takes a face clicked off any region.
func face_profiles() -> unit!:
let editor = Luce3D()
editor.app.layout(1400.0, 900.0)
let w = editor.workspace
cad(w)
node_commands.add_node(w, "Solid Box", 0.0, 0.0)
let box = w.network.selected
selection_commands.set_mode(w, w.level_of(2))
editor.panels.refresh()
let mesh = w.geometry else trap("no pick mesh")
var top = -1
for face in 0..<mesh.face_count():
if top < 0 and math.abs(mesh.face_center(face).y - 10.0) < 1e-6:
top = face
selection_commands.choose_component(w, top, false)
editor.panels.actions.refresh()
editor.panels.actions.extrude_face.trigger()
let extrude = w.network.selected
let node = w.network.require(extrude)
assert(node.kind == "Extrude" and node.inputs[0] == box and extrude_inputs.profile_face(node.texts[0]) == face_facing(w, box, Vector3(0.0, 1.0, 0.0)))
assert(volume_is(w, extrude, 8000.0 + 4000.0) and node.automatic == "Join")
# Down 5 into the box: Auto cuts the face's area away.
node_commands.set_parameter(w, cad_features.distance_slot, -5.0)
assert(volume_is(w, extrude, 8000.0 - 2000.0) and node.automatic == "Cut")
editor.close()
## A 20 mm box with a 4 mm square sketched on the ground 30 below its
## middle.
func box_and_square(w: Workspace) -> (int, int)!:
cad(w)
node_commands.add_node(w, "Solid Box", 0.0, 0.0)
let box = w.network.selected
node_commands.add_node(w, "Sketch", 0.0, 120.0)
node_commands.set_parameter(w, 0, 1.0)
node_commands.set_parameter(w, 1, -30.0)
node_commands.set_text(w, 0, sketch_commands.rectangle_text(0.0, 0.0, 4.0, 4.0))
node_commands.add_node(w, "Extrude", 0.0, 240.0)
return (box, w.network.selected)
## Start: Object, start offsets with To object and All, Extend.
func starts_and_extends() -> unit!:
let w = Workspace()
let (box, extrude) = box_and_square(w)
let bottom = face_facing(w, box, Vector3(0.0, -1.0, 0.0))
let top = face_facing(w, box, Vector3(0.0, 1.0, 0.0))
# Start offset 15 (y -15) up To object the bottom (y -10): 16 × 5
# joined.
node_commands.set_parameter(w, cad_features.start_slot, 1.0)
node_commands.set_parameter(w, cad_features.start_offset_slot, 15.0)
node_commands.set_parameter(w, cad_features.extent_slot, 1.0)
node_commands.set_text(w, cad_features.face_text, bottom)
assert(volume_is(w, extrude, 8000.0 + 80.0))
# Extend To body (picked by its top face): the same; Through body: out
# of the top, the square joined all the way, 16 × 25 more.
node_commands.set_text(w, cad_features.face_text, top)
node_commands.set_parameter(w, cad_features.extend_slot, 2.0)
assert(volume_is(w, extrude, 8000.0 + 80.0))
node_commands.set_parameter(w, cad_features.extend_slot, 3.0)
assert(volume_is(w, extrude, 8000.0 + 80.0 + 0.0))
# Cut through the body: a square hole.
node_commands.set_parameter(w, cad_features.operation_slot, 3.0)
assert(volume_is(w, extrude, 8000.0 - 16.0 * 20.0))
node_commands.set_parameter(w, cad_features.operation_slot, 0.0)
node_commands.set_parameter(w, cad_features.extend_slot, 0.0)
# All from the start offset: cut through, the same hole.
node_commands.set_parameter(w, cad_features.extent_slot, 2.0)
node_commands.set_parameter(w, cad_features.operation_slot, 3.0)
assert(volume_is(w, extrude, 8000.0 - 16.0 * 20.0))
node_commands.set_parameter(w, cad_features.operation_slot, 0.0)
node_commands.set_parameter(w, cad_features.extent_slot, 0.0)
# Start: Object, the box's top picked: 10 up from it, a new body
# beside (joined, touching: 8000 + 160).
tool_picks.start_named(w, extrude, "Start object")
assert(w.prompt != none and w.prompt_level() == w.level_of(2))
let mesh = w.geometry else trap("no pick mesh")
var face = -1
for at in 0..<mesh.face_count():
if face < 0 and math.abs(mesh.face_center(at).y - 10.0) < 1e-6:
face = at
selection_commands.choose_component(w, face, false)
let node = w.network.require(extrude)
assert(w.prompt == none and node.texts[cad_features.start_face_text] == top and int(node.values[cad_features.start_slot]) == cad_features.start_object)
node_commands.select_node(w, extrude)
node_commands.set_parameter(w, cad_features.start_offset_slot, 0.0)
node_commands.set_parameter(w, cad_features.distance_slot, 10.0)
assert(volume_is(w, extrude, 8000.0 + 160.0))
## Two boxes side by side, a square sketched under both cut up through
## all: Objects To Cut picks the left one alone; Auto-select cuts both,
## each apart (two bodies stay two).
func objects_to_cut() -> unit!:
let w = Workspace()
cad(w)
node_commands.add_node(w, "Solid Box", 0.0, 0.0)
let left = w.network.selected
node_commands.add_node(w, "Transform", 0.0, 100.0)
node_commands.set_parameter(w, 1, -15.0)
let moved = w.network.selected
node_commands.add_node(w, "Solid Box", 200.0, 0.0)
let right = w.network.selected
node_commands.add_node(w, "Transform", 200.0, 100.0)
node_commands.set_parameter(w, 1, 15.0)
let moved_right = w.network.selected
node_commands.add_node(w, "Merge", 100.0, 200.0)
let both = w.network.selected
node_commands.connect(w, moved, both, 0)
node_commands.connect(w, moved_right, both, 1)
node_commands.add_node(w, "Sketch", 100.0, 300.0)
node_commands.set_parameter(w, 0, 1.0)
node_commands.set_parameter(w, 1, -30.0)
# 60 x 4 across both boxes (x -30..30).
node_commands.set_text(w, 0, sketch_commands.rectangle_text(0.0, 0.0, 60.0, 4.0))
node_commands.add_node(w, "Extrude", 100.0, 400.0)
let extrude = w.network.selected
node_commands.set_parameter(w, cad_features.extent_slot, 2.0)
node_commands.set_parameter(w, cad_features.operation_slot, 3.0)
# Each box loses 20 x 4 x 20 (the strip crosses each whole), and they
# stay two bodies.
assert(volume_is(w, extrude, 16000.0 - 2.0 * 1600.0))
assert(CadGeometry.model_count(w.network.evaluate_data(extrude).geometry) == 2)
# Pick bodies: the left box alone.
tool_picks.start_named(w, extrude, "Objects To Cut")
assert(w.prompt_level() == 0)
let mesh = w.geometry else trap("no pick mesh")
var face = -1
for at in 0..<mesh.face_count():
if face < 0 and mesh.face_center(at).x < -20.0:
face = at
selection_commands.choose_component(w, face, false)
tool_prompts.accept_prompt(w)
let node = w.network.require(extrude)
assert(node.texts[cad_features.bodies_text] != "" and not (";" in node.texts[cad_features.bodies_text]))
assert(volume_is(w, extrude, 16000.0 - 1600.0))
# Auto-select again: both.
node_commands.select_node(w, extrude)
node_commands.set_text(w, cad_features.bodies_text, "")
assert(volume_is(w, extrude, 16000.0 - 2.0 * 1600.0))
_ = left
_ = right
## A 1 x 1 square 1..2 out along X on XY, about the Y axis, To the face
## x = 0 of a 4 x 20 x 20 wall standing at x -4..0: a quarter tube, either
## way (Flip).
func revolve_to() -> unit!:
let w = Workspace()
cad(w)
node_commands.add_node(w, "Solid Box", 0.0, 0.0)
node_commands.set_parameter(w, 0, 4.0)
node_commands.set_parameter(w, 1, 20.0)
node_commands.set_parameter(w, 2, 20.0)
node_commands.add_node(w, "Transform", 0.0, 100.0)
node_commands.set_parameter(w, 1, -2.0)
let wall = w.network.selected
node_commands.add_node(w, "Sketch", 0.0, 200.0)
node_commands.set_parameter(w, 0, 0.0)
node_commands.set_text(w, 0, sketch_commands.rectangle_text(1.5, 0.5, 1.0, 1.0))
node_commands.add_node(w, "Revolve", 0.0, 300.0)
let revolve = w.network.selected
node_commands.set_parameter(w, cad_features.axis_slot, 2.0)
node_commands.set_parameter(w, cad_features.operation_slot, 1.0)
# Pick object: the wall's face at x = 0.
tool_picks.start_named(w, revolve, "Object")
let mesh = w.geometry else trap("no pick mesh")
var face = -1
for at in 0..<mesh.face_count():
if face < 0 and math.abs(mesh.face_center(at).x) < 1e-6:
face = at
selection_commands.choose_component(w, face, false)
let node = w.network.require(revolve)
assert(int(node.values[cad_features.revolve_type_slot]) == cad_features.revolve_to and node.texts[cad_features.revolve_face_text] == face_facing(w, wall, Vector3(1.0, 0.0, 0.0)))
# A new body beside the wall: the wall and the quarter tube.
let quarter = math.pi * 3.0 / 4.0
assert(volume_is(w, revolve, 1600.0 + quarter))
node_commands.select_node(w, revolve)
node_commands.set_parameter(w, cad_features.revolve_flip_slot, 1.0)
assert(volume_is(w, revolve, 1600.0 + quarter))
## A 4 x 10 x 20 rib: Full round of its top (Pick center face): radius
## 2. A 20 box: a fillet by chord length √2 (radius 1); three chamfers of
## 2 at a corner, Miter (7886) and Chamfer (the tip 8 / 12 more).
func blend_options() -> unit!:
let w = Workspace()
cad(w)
node_commands.add_node(w, "Solid Box", 0.0, 0.0)
node_commands.set_parameter(w, 0, 4.0)
node_commands.set_parameter(w, 1, 10.0)
node_commands.set_parameter(w, 2, 20.0)
node_commands.add_node(w, "Fillet", 0.0, 100.0)
let fillet = w.network.selected
tool_picks.start_named(w, fillet, "Center face")
let mesh = w.geometry else trap("no pick mesh")
var top = -1
for at in 0..<mesh.face_count():
if top < 0 and math.abs(mesh.face_center(at).y - 5.0) < 1e-6:
top = at
selection_commands.choose_component(w, top, false)
assert(int(w.network.require(fillet).values[cad_blends.type_slot]) == cad_blends.full_round_type)
assert(volume_is(w, fillet, 800.0 - 40.0 * 4.0 * (1.0 - math.pi * 0.25)))
# A 20 box's front top edge by chord length √2: radius 1.
let v = Workspace()
cad(v)
node_commands.add_node(v, "Solid Box", 0.0, 0.0)
let box = v.network.selected
let model = CadGeometry.model(v.network.evaluate_data(box).geometry, 0)
let front: list[int] = []
let corner: list[int] = []
for face in 0..<model.face_count():
for use in 0..<model.face_edge_count(face):
let id = model.face_edge_id(face, use)
let a = model.face_edge_point(face, use, 0.0)
let b = model.face_edge_point(face, use, 1.0)
if a.y > 9.99 and b.y > 9.99 and a.z > 9.99 and b.z > 9.99 and not (id in front):
front.append(id)
let at = a.subtract(Vector3(10.0, 10.0, 10.0)).length() < 1e-9 or b.subtract(Vector3(10.0, 10.0, 10.0)).length() < 1e-9
if at and not (id in corner):
corner.append(id)
node_commands.add_node(v, "Fillet", 0.0, 100.0)
let chord = v.network.selected
node_commands.set_text(v, 0, CadModeling.edge_references(model, front))
node_commands.set_parameter(v, cad_blends.radius_type_slot, 1.0)
node_commands.set_parameter(v, cad_blends.chord_slot, math.sqrt(2.0))
assert(volume_is(v, chord, 8000.0 - 20.0 * (1.0 - math.pi * 0.25)))
# Variable: 1 at the start to 3 at the end, straight: ∫ r² = 13 / 3;
# a point 2 at the middle, smooth, keeps it a body.
node_commands.set_parameter(v, cad_blends.radius_type_slot, 2.0)
node_commands.set_parameter(v, cad_blends.size_slot, 1.0)
node_commands.set_parameter(v, cad_blends.end_radius_slot, 3.0)
node_commands.set_parameter(v, cad_blends.smooth_slot, 0.0)
node_commands.set_parameter(v, cad_blends.chain_slot, 0.0)
assert(volume_is(v, chord, 8000.0 - 20.0 * (1.0 - math.pi * 0.25) * 13.0 / 3.0))
# G2: the G2 section's area at unit radius, 0.17679, for the same law.
node_commands.set_parameter(v, cad_blends.continuity_slot, 1.0)
assert(volume_is(v, chord, 8000.0 - 20.0 * 0.17678573604910766 * 13.0 / 3.0))
node_commands.set_parameter(v, cad_blends.continuity_slot, 0.0)
node_commands.set_text(v, cad_blends.points_text, "0.5 2")
node_commands.set_parameter(v, cad_blends.smooth_slot, 1.0)
assert(CadGeometry.model_count(v.network.evaluate_data(chord).geometry) == 1)
# Tangency weight on a constant radius: 1 the kernel's plain fillet,
# 2 keeping more of the corner, at G1 (a conic) and G2.
node_commands.set_parameter(v, cad_blends.radius_type_slot, 0.0)
node_commands.set_parameter(v, cad_blends.size_slot, 4.0)
for continuity in [0, 1]:
node_commands.set_parameter(v, cad_blends.continuity_slot, float(continuity))
node_commands.set_parameter(v, cad_blends.tangency_slot, 1.0)
let plain = volume(v, chord)
let kernel = CadModeling.filleted(model, CadModeling.edge_references(model, front), 4.0, "k", continuity + 1, false).tessellate(32)
var expected = 0.0
for triangle in 0..<kernel.index_count() // 3:
let a = kernel.vertex(kernel.index(triangle * 3)).position
let b = kernel.vertex(kernel.index(triangle * 3 + 1)).position
let c = kernel.vertex(kernel.index(triangle * 3 + 2)).position
expected += a.dot(b.cross(c)) / 6.0
assert(math.abs(plain - expected) < 1e-6, f"{plain} against {expected}")
node_commands.set_parameter(v, cad_blends.tangency_slot, 2.0)
assert(volume(v, chord) > plain + 1.0)
node_commands.set_parameter(v, cad_blends.tangency_slot, 1.0)
node_commands.set_parameter(v, cad_blends.continuity_slot, 0.0)
# Fusion's Setback corner type: three G1 fillets at the corner, a
# patch instead of a ball (more faces).
node_commands.select_node(v, box)
node_commands.add_node(v, "Fillet", 400.0, 100.0)
let corner_fillet = v.network.selected
node_commands.set_text(v, 0, CadModeling.edge_references(model, corner))
node_commands.set_parameter(v, 0, 3.0)
let balls = CadGeometry.model(v.network.evaluate_data(corner_fillet).geometry, 0).face_count()
node_commands.set_parameter(v, cad_blends.fillet_corner_slot, 1.0)
assert(CadGeometry.model(v.network.evaluate_data(corner_fillet).geometry, 0).face_count() > balls)
# Chamfer corners.
node_commands.select_node(v, box)
node_commands.add_node(v, "Chamfer", 200.0, 100.0)
let chamfer = v.network.selected
node_commands.set_text(v, 0, CadModeling.edge_references(model, corner))
node_commands.set_parameter(v, 0, 2.0)
assert(int(v.network.require(chamfer).values[cad_blends.corner_slot]) == 0)
# Flat faces only: the volumes are exact, the tip told apart.
assert(math.abs(volume(v, chamfer) - (7886.0 - 8.0 / 12.0)) < 1e-6)
node_commands.set_parameter(v, cad_blends.corner_slot, 1.0)
assert(math.abs(volume(v, chamfer) - 7886.0) < 1e-6)
## A box with a finished sketch on top (a disc and a line), the sketch
## shown, nothing selected: at the Faces level a click in the disc picks its
## profile, not the top face beneath; Extrude takes it. At Smart, the line
## clicked is picked, and with the disc picked a Revolve takes the line as
## its axis.
func shown_sketch() -> unit!:
let editor = Luce3D()
editor.app.layout(1600.0, 1000.0)
let w = editor.workspace
cad(w)
node_commands.add_node(w, "Solid Box", 0.0, 0.0)
node_commands.add_node(w, "Sketch", 0.0, 120.0)
let sketch = w.network.selected
node_commands.set_parameter(w, 0, 1.0)
node_commands.set_parameter(w, 1, 10.0)
let s = CadSketch.parse("")
_ = s.add_circle(s.add_point(3.0, 0.0), 2.0)
_ = s.add_line(s.add_point(-6.0, -6.0), s.add_point(-6.0, 6.0))
node_commands.set_text(w, 0, s.text())
node_commands.select_nothing(w)
w.network.set_display(sketch)
w.view.yaw = 0.4
w.view.pitch = 0.9
w.view.distance = 60.0
w.view.target = Vector3()
w.view.update_camera()
selection_commands.set_mode(w, w.level_of(2))
render(editor)
assert(not w.sketching() and editor.panels.view.shown.node() != none)
# The disc's middle: (3, 10, 0) on the top (the XZ plane's x is X).
click(editor, Vector3(3.0, 10.0, 0.0))
assert(w.sketch_profiles.length == 1 and w.sketch_picked_on == sketch and w.selection == none, f"{w.sketch_profiles}")
editor.panels.actions.refresh()
assert(editor.panels.actions.extrude_profiles.is_enabled())
editor.panels.actions.extrude_profiles.trigger()
let extrude = w.network.require(w.network.selected)
assert(extrude.kind == "Extrude" and extrude.inputs[0] == sketch and extrude.texts[0] != "")
# Smart: the line (entity 4), then the disc with Shift; Revolve takes
# the line.
w.network.set_display(sketch)
node_commands.select_nothing(w)
selection_commands.set_mode(w, smart_level)
render(editor)
click(editor, Vector3(-6.0, 10.0, 2.0))
assert(w.sketch_picks.length == 1, f"{w.sketch_picks}")
# (Off the disc's center point, which Smart would pick.)
click(editor, Vector3(4.2, 10.0, 0.6), shift = true)
assert(w.sketch_profiles.length == 1)
editor.panels.actions.refresh()
editor.panels.actions.revolve_profiles.trigger()
let revolve = w.network.require(w.network.selected)
assert(revolve.kind == "Revolve" and revolve.texts[cad_features.axis_text] == cad_features.line_axis(4) and w.prompt == none, revolve.texts[cad_features.axis_text])
editor.close()
## A click (down and up) on the viewport where world point `p` is.
func click(editor: Luce3D, p: Vector3, shift: bool = false) -> unit!:
let bounds = editor.panels.view.layout().bounds()
let at = project(editor.workspace, p, bounds.width, bounds.height)
for kind in [EventKind.pointer_moved, EventKind.pointer_down, EventKind.pointer_up]:
editor.app.dispatch(Event(kind = kind, x = bounds.x + at[0], y = bounds.y + at[1], button = 0, shift = shift))
render(editor)