dymokomi/luced-3d
Source of release 0.11.6
0.11.6 / src / tool_sketch.luc
## Sketch: curves on a plane (an origin plane, or a flat face of the input
## body, its loops projected), constrained and dimensioned, edited in the
## viewport (sketch_node.luc, sketch_editor.luc). A node of a CAD network;
## in Edit CAD a sketch is an object of the model (edit_cad_sketches.luc).
from tool_record import Tool, ToolEntry, Pick, Invocation
from geometry_data import GeometryData
from parameter_rows import Parameter, number, menu
from edit_types import face_level
import pick_kinds
import sketch_node
import cad_cook
pub func entry() -> ToolEntry:
return ToolEntry(sketch_node.kind_name, sketch_node.kind_name, "sketch", "Sketch", [cad_cook.context], [], made)
func made() -> Tool:
return entry().tool("Create", "Sketch", "Curves on a plane or a flat face, constrained and dimensioned", picks(), rows(), cook, gesture = "sketch")
## The face it is on (Plane: Face), kept by name.
func picks() -> list[Pick]:
return [Pick("Face", [face_level], kind = pick_kinds.face, slot = 1, needed = optional, taken = on_face, summary = face_or_none, prompt = "Click the flat face to sketch on; Esc cancels",
doc = "The input body's face the sketch is on (Plane: Face), kept by its name so it stays that face as the body changes.")]
func optional(values: list[float], texts: list[str], wired: bool) -> bool:
return false
func on_face(values: list[float], picked: str):
values[0] = float(sketch_node.face_plane)
func face_or_none(text: str) -> str:
return text if text != "" else "None picked"
func cook(call: Invocation, data: GeometryData, tag: str) -> GeometryData!:
return sketch_node.evaluate_sketch(call.numbers, call.texts, data)
## Its plane (also Edit CAD's Redefine Sketch Plane step's rows).
pub func rows() -> list[Parameter]:
return [menu("Plane", 0, sketch_node.plane_names(), 1.0, "The plane the sketch is drawn on: XY (front), XZ (the ground), YZ (side), or a flat face of the input body (Pick face)."),
number("Offset", 1, 0.0, -100000.0, 100000.0, 1.0, "How far the plane is moved along its normal.", soft = 100.0)]