Skip to content

Edge

A straight line segment between two vertices in the model.

Edges are the most fundamental geometry in SketchUp — every face is bounded by edges, and standalone edges can be used for drawing 3D lines.

When edges are joined smoothly (like the segments of a circle), they share a Curve or ArcCurve.

let model = await SketchUpApi.getActiveModel();
// Draw an edge and a circle, so we have some to play with.
await model.performOperation(op => {
// First a simple edge.
op.createEdge(
model, [[0, 0, 0], [100, 0, 0]]
);
// Then a circle.
const center = [200, 0, 0];
const normal = [0, 0, 1];
const radius = 50;
const segments = 12;
op.createCircle(
model, center, normal, radius, segments
);
}, 'Draw edge and circle');
// Use entities.get() to return all of the edges.
let edges = await model.entities.get({
filterBy: { types: ['Edge'] }
});
let simpleEdge = edges[0];
let firstCircleEdge = edges[1];
console.log(simpleEdge.start.x, simpleEdge.end.x);
// => 0 100
console.log(await simpleEdge.getCurve());
// => undefined
console.log(await firstCircleEdge.getCurve());
// => ArcCurve { edges: [...], ... }

SketchupOperation

  • BaseDrawingElement

readonly attributes: Attributes

The attribute dictionaries attached to this element. Attributes store custom key-value metadata that extensions can read and write.

BaseDrawingElement.attributes


readonly castsShadows: boolean

Whether this element casts shadows onto other geometry.

BaseDrawingElement.castsShadows


readonly curve: ArcCurveRef | CurveRef | undefined

A reference to the curve this edge belongs to, if any. Edges that form arcs or smooth curves share a single Curve or ArcCurve parent. Call getCurve to fetch the full curve object.


readonly end: Vertex

The vertex at the end of this edge.


readonly hidden: boolean

Whether this element is hidden. Hidden elements don’t appear in the viewport unless the user enables “View > Hidden Geometry.”

BaseDrawingElement.hidden


readonly id: number

The persistent ID that uniquely identifies this edge.


readonly materialRef: MaterialRef | undefined

A reference to the material applied to this element, if any. Call getMaterial() to fetch the full Material object with color and texture data.

BaseDrawingElement.materialRef


readonly receivesShadows: boolean

Whether this element receives shadows cast by other geometry.

BaseDrawingElement.receivesShadows


readonly smooth: boolean

Whether this edge is smoothed, causing adjacent faces to render with blended normals instead of a hard crease.


readonly soft: boolean

Whether this edge is soft — hidden from view but still logically connecting two faces. Soft edges also smooth their adjacent faces.


readonly start: Vertex

The vertex at the start of this edge.


readonly tagRef: TagRef | undefined

A reference to the tag (formerly “layer”) assigned to this element. Call getTag() to fetch the full Tag object.

BaseDrawingElement.tagRef


readonly type: Edge = EntityType.Edge

get sketchupId(): SketchupId

JS API identifier for this edge. Pass it to API methods that accept a sketchupId.

SketchupId

BaseDrawingElement.sketchupId


get typeName(): string

Returns a named variant of the type field.

SDK 2.35.0

string

getBounds(): Promise<BoundingBox>

Fetches the axis-aligned bounding box for this element from SketchUp.

Promise<BoundingBox>

let model = await SketchUpApi.getActiveModel();
let all = await model.entities.get();
let element = all[0];
let box = await element.getBounds();
console.log(box.min.x, box.min.y, box.min.z);
console.log(box.max.x, box.max.y, box.max.z);

SDK 2.30.0

BaseDrawingElement.getBounds


getCurve(): Promise<ArcCurve | Curve | undefined>

Fetches the full Curve or ArcCurve that this edge belongs to. Many edges in SketchUp are segments of a larger curve (like the edges forming a circle). This method resolves the lightweight curve reference into the complete object. Returns undefined if this edge isn’t part of a curve.

Promise<ArcCurve | Curve | undefined>

let model = await SketchUpApi.getActiveModel();
let curves = await model.entities.getCurves();
let edge = curves[0].edges[0];
let curve = await edge.getCurve();
console.log(curve.type);
// => 24 (ArcCurve)

SDK 2.23.0 Protocol 1.20.0


getMaterial(): Promise<Material | undefined>

Fetches the material applied to this element. Returns undefined if the element uses the default material.

Promise<Material | undefined>

let model = await SketchUpApi.getActiveModel();
let all = await model.entities.get();
let element = all[0];
let mat = await element.getMaterial();
if (mat) {
console.log(mat.name, mat.color.toHex());
}

SDK 2.30.0

BaseDrawingElement.getMaterial


getTag(): Promise<Tag | undefined>

Fetches the tag assigned to this element. Most elements have a tag — even those on the default “Untagged” tag. Returns undefined only if the tag reference is missing.

Promise<Tag | undefined>

let model = await SketchUpApi.getActiveModel();
let all = await model.entities.get();
let element = all[0];
let tag = await element.getTag();
if (tag) {
console.log(tag.name);
}

SDK 2.30.0

BaseDrawingElement.getTag


refresh(): Promise<Edge>

Re-fetches this edge from SketchUp to get its current state. Because Edge is a snapshot, it can become stale if the model changes. Call refresh() to get an up-to-date copy.

Promise<Edge>

A new Edge reflecting the current model state. Throws if the edge has been deleted.

let model = await SketchUpApi.getActiveModel();
let edges = await model.entities.get({
filterBy: { types: ['Edge'] },
});
let fresh = await edges[0].refresh();
console.log(fresh.start.x, fresh.start.y);

toString(): string

Returns a string representation of an object.

string

readonly materialId: number | undefined

BaseDrawingElement.materialId


readonly tagId: number | undefined

BaseDrawingElement.tagId


get bounds(): Promise<BoundingBox>

Promise<BoundingBox>

BaseDrawingElement.bounds


get tag(): Promise<Readonly<Tag> | undefined>

Promise<Readonly<Tag> | undefined>

BaseDrawingElement.tag