Luce packages
LuceLuce BaseLuciaOS

dymokomi/luced-3d

Source of release 0.11.8

0.11.8 / src / tool_align.luc

## Align (Alias's Object Edit › Align): a surface's edge or a curve's end
## (the input) made G0 to G3 with a master (an edge, a curve, a face for
## Project and U/V, or a temporary isoparm), a second master for another
## side; aligned rows stay aligned as CVs are dragged later
## (edit_cad_align.luc, align_ops.luc). The node keeps its picks as words;
## an Edit CAD step takes the edge or curve end picked, then waits for its
## master.
from luce_3d.graphics import Vector3
from tool_record import Tool, ToolEntry, Pick
from edit_types import edge_level, curve_level
import pick_kinds
import align_ops
import edit_cad_align
import cad_cook

pub func entry() -> ToolEntry:
    return ToolEntry(align_ops.align_verb, align_ops.align_verb, "align-surface", "Surfaces", [cad_cook.context], [cad_cook.edit_kind], made)

func made() -> Tool:
    return entry().tool("Modify", "Align", "Make a surface's edge or a curve's end meet a master G0 to G3", picks(), align_ops.rows(), edit_cad_align.cook,
                        numbers = align_ops.starting(), handles = true, waits = waits)

func picks() -> list[Pick]:
    return [Pick("Input edge", [edge_level, curve_level], "Align: select the input first: a surface's edge (Edges level) or a curve near its end (Curves level)",
                 kind = pick_kinds.align_input, slot = align_ops.input_text, step = align_ops.input_text,
                 doc = "The edge that moves (a surface's edge; at the Curves level a curve's end), kept as its face and where it was clicked."),
            Pick("Master", [edge_level, curve_level], kind = pick_kinds.align_master, slot = align_ops.master_text, step = align_ops.master_text,
                 doc = "What it aligns to: an edge, a curve, a face (Project, U/V), or a double-click on a surface for an isoparm."),
            Pick("Second master", [edge_level, curve_level], kind = pick_kinds.align_master, slot = align_ops.second_text, step = align_ops.second_text, needed = optional,
                 taken = beside, doc = "A second master for another side of the input (optional).")]

func optional(values: list[float], texts: list[str], wired: bool) -> bool:
    return false

## The second master's side of the input: the one nearest its pick.
func beside(values: list[float], picked: str):
    let near = edit_cad_align.words_point(picked) else Vector3()
    values[align_ops.second_near_slot] = near.x
    values[align_ops.second_near_slot + 1] = near.y
    values[align_ops.second_near_slot + 2] = near.z

func waits(values: list[float], texts: list[str], wired: bool) -> str:
    return align_ops.waits_for(texts)