Skip to content

Reference Line

Reference line management — create, query, and delete reference lines. A reference line is a 2D guide line (or arc) in the Snaptrude scene, typically used for grid lines and alignment guides. Reference lines carry properties such as grid tags, labels, and line styles. All methods are host API calls that return Promises and support undo/redo via Snaptrude's command system. Accessed via snaptrude.entity.referenceLine.

Types

PluginReferenceLineGetProperty

Available properties that can be queried on a reference line via get.

ValueReturn TypeDescription
"curve"CurveHandleThe curve geometry of the reference line, as an opaque handle

PluginReferenceLineGetResult

A partial object — only the properties that were requested in properties will be present.

PropertyTypeDescription
curveCurveHandle (optional)The curve geometry of the reference line, as an opaque handle

Functions

createMulti(profile)

Create multiple reference lines from a profile.

Each curve in the given profile becomes a separate reference line.

  • Parameters:
    • profile: ProfileHandle — A profile handle whose curves define the reference lines to create
  • Returns: { referenceLineIds: string[] } — IDs of the created reference lines
  • Throws: If reference line creation fails
ts
const { vec3 } = snaptrude.core.math;

const start = await vec3.new(0, 0, 0);
const mid = await vec3.new(10, 0, 0);
const end = await vec3.new(10, 0, 10);
const l1 = await snaptrude.core.geom.create.line(start, mid);
const l2 = await snaptrude.core.geom.create.line(mid, end);
const profile = await snaptrude.core.geom.create.profileFromCurves([l1, l2]);

const { referenceLineIds } = await snaptrude.entity.referenceLine.createMulti(profile);

get(referenceLineId, properties)

Get properties of a reference line by its ID.

Only the properties listed in properties are returned — unlisted properties will be undefined in the result.

  • Parameters:
    • referenceLineId: string — The unique reference line ID
    • properties: PluginReferenceLineGetProperty[] — Array of property names to retrieve (see Types)
  • Returns: PluginReferenceLineGetResult — A partial object containing only the requested properties
  • Throws: If the reference line does not exist
ts
const result = await snaptrude.entity.referenceLine.get("some-ref-line-id", ["curve"]);
// result.curve is an opaque CurveHandle; a dedicated curve read API for its
// coordinates is exposed separately via `snaptrude.core.geom.curve`.

getAll()

Get the IDs of all reference lines in the current project.

Returns every reference line across all stories. Use the returned IDs with get to query individual reference line properties.

  • Returns: { referenceLineIds: string[] } — IDs of all reference lines in the project
ts
const { referenceLineIds } = await snaptrude.entity.referenceLine.getAll();
console.log(`Project has ${referenceLineIds.length} reference lines`);

delete(referenceLineId)

Delete a reference line by its ID.

Permanently removes the reference line and its associated mesh from the scene. This operation is undoable via Snaptrude's command system.

  • Parameters:
    • referenceLineId: string — The unique reference line ID to delete
  • Returns: void — Returns nothing on success
  • Throws: If the reference line does not exist
ts
await snaptrude.entity.referenceLine.delete("some-ref-line-id");

Errors

Failed calls reject with a typed PluginError — see Error Handling. Conditions specific to this namespace:

CodeThrown byWhendetails
HANDLE_INVALIDcreateMultiThe profile handle cannot be resolved
HANDLE_INVALIDget, deleteThe id is unknown or does not belong to a reference line
PRECONDITION_FAILEDcreateMultiThe profile has no curve segments to create lines fromhandles — the offending profile id

getAll never throws — it returns an empty array when the project has no reference lines.