Luce packages
LuceLuce BaseLuciaOS

dymokomi/luced-3d

Source of release 0.11.8

0.11.8 / src / tool_replace_face.luc

## Replace Face (Fusion 360's): faces (with Tangent chain, those meeting
## them smoothly) moved onto the target faces' surface (edit_cad_faces.luc).
## The node keeps both by name; an Edit CAD step takes the faces picked,
## then waits for the targets.
from tool_record import Tool, ToolEntry, Pick, Invocation
from geometry_data import GeometryData
from parameter_rows import Parameter, toggle
from edit_types import face_level, patch_level
import pick_kinds
import edit_cad_faces
import cad_cook

pub func entry() -> ToolEntry:
    return ToolEntry("Replace Face", "Replace Face", "replace-face", "Modify", [cad_cook.context], [cad_cook.edit_kind], made)

func made() -> Tool:
    return entry().tool("Modify", "Faces", "Move faces onto the surface of target faces", picks(), rows(), cook, waits = waits)

func picks() -> list[Pick]:
    return [Pick("Faces", [face_level, patch_level], kind = pick_kinds.faces, slot = 0, doc = "The faces replaced."),
            Pick("Target faces", [face_level], kind = pick_kinds.faces, slot = 1, step = edit_cad_faces.target_text, doc = "The faces (one surface, or a solid's faces) the faces are moved onto.")]

func waits(values: list[float], texts: list[str], wired: bool) -> str:
    if texts[0].trim() == "":
        return "Pick the faces to replace"
    if texts[1].trim() == "":
        return "Pick the target faces"
    return ""

func cook(call: Invocation, data: GeometryData, tag: str) -> GeometryData!:
    if not call.node:
        return cad_cook.face_step(call, data, tag)
    let waiting = waits(call.numbers, call.texts, false)
    if waiting != "":
        return data.passed(waiting)
    let mesh = cad_cook.node_mesh(data, call.verb)
    return cad_cook.node_face_step(call, "Replace Face", data, mesh, cad_cook.picked(call, mesh, 0, false), [call.text(1), ""], 8, tag)

func rows() -> list[Parameter]:
    return [toggle("Tangent chain", edit_cad_faces.replace_chain_slot, 1.0, "Each face replaced brings the faces meeting it smoothly.")]