Skip to main content

Module external_ref

Module external_ref 

Source
Expand description

Project solid edges into a sketch as fixed construction references.

Projected polylines become lines, circles, arcs, or line-chain fallbacks. Ground constraints pin the generated points. Edge names identify persisted references, so picking an edge again updates its coordinates in place.

The sketch feature’s projectedEdges list is the ONE record of which edges a sketch links: an edge picked inside the editor is written into that list on Finish, and an edge put into the list from the feature dialog is materialized here on the next enter, through the same classifier. The persistentData.externalRefs entries only remember which points and geometry each listed edge became. When a listed edge stops resolving (its feature was deleted, or a regeneration lost the edge) the link is RELEASED: the geometry stays in the sketch as ordinary fixed construction geometry (release_ref), the entry and the list item go.

Structs§

ExternalRef
A per-session external-reference mapping: the linked scene edge (by name + owning solid) and the sketch entities materialized for it. Persisted to / loaded from persistentData.externalRefs so a linked edge round-trips a commit + re-enter.

Enums§

EdgeLink
The classification of a projected edge polyline, in plane (u, v) coordinates.

Constants§

LINKS_LISTED_KEY
The persistentData key a unified commit stamps: once it is set, the projectedEdges list and the externalRefs entries describe the SAME set of edges, so an entry whose edge the dialog no longer lists was removed by the user. A document without it predates the unification: its entries were never listed, so they are adopted into the list, never released.

Functions§

add_copied_edge
Materialize an EdgeLink as PLAIN sketch geometry, a copy that nothing keeps up to date: free points (not fixed, construction or external), no grounds, and each geometry carrying note. A copied end that lands on a plain point already in the sketch (within 1e-6·extent) reuses it, so the edges of one loop, copied one by one, join into a closed profile. Returns the geometry ids.
add_external_ref
Materialize an EdgeLink into the doc: push external-ref points (fixed, construction, externalReference) with a ⏚ ground each, then the construction geometry referencing them. Returns (point_ids, geom_ids).
classify_uv
Classify a projected polyline (in plane (u, v)) as a straight line, a circle / arc, or a polyline fallback. Tolerances are RELATIVE to the polyline’s extent so the same thresholds work at any sketch scale:
ensure_origin_point
Ensure the sketch carries the PART ORIGIN reference point: world (0, 0, 0) projected onto plane, under the reserved id brep_kernel::SKETCH_ORIGIN_POINT_ID, flagged fixed + construction + external reference, with one ⏚ ground (reserved id too). Adds it when missing and re-projects it when the plane moved. It is something to constrain to inside the sketch only — the kernel never publishes it. Returns whether the doc changed.
is_origin_id
Whether id names the reserved part-origin point (or its ground).
link_or_update
Link (or update) a picked scene edge into the sketch as an external reference.
listed_edge_names
The projectedEdges list a Finish writes: every name the feature listed before, in its order, minus the ones whose link the session dropped (deleted in the editor, or released), plus every live link the list did not name yet. kept_unlinked are listed names that had nothing to materialize at enter (the edge did not resolve in the backdrop) — they stay listed for the kernel to report.
project_polyline
Project a world-space polyline into the plane’s (u, v) frame (orthogonal projection; the off-plane component is dropped). Mirrors the previous world→UV projection applied per vertex.
prune_dead_refs
Drop every external-reference entry whose materialized entities no longer resolve in doc — i.e. the linked edge’s points / geometry were deleted. A dropped entry frees its edge_name so the SAME edge can be RE-LINKED: without this, the stale entry (keyed by edge_name, holding now-dangling point_ids) makes link_or_update’s dedup take the “structure matches” branch, find every point missing (doc.point_mut → None), and return false — permanently blocking the re-link. Called both after a delete AND on sketch-enter (to heal docs already poisoned by that pre-fix delete). Returns whether any entry was pruned.
release_ref
Release a linked edge whose source edge is gone: its materialized points stay where they are, fixed and grounded (⏚), but stop being external references, so the line / arc / circle becomes an ordinary sketch entity the user owns. It stays CONSTRUCTION: flipping that on a feature deletion would add profile edges and change what a downstream extrude builds. Returns whether any point changed (false when the entry’s points are all gone).
release_ref_json
release_ref on the persisted JSON doc (persistentData.sketch), for the regenerate-time fold that cannot go through the editor: every point the entry materialized loses externalReference and keeps (or regains) fixed; nothing else in the doc is touched, so the fold is lossless. Returns whether any point changed.