Skip to content

ConstructionLine

A guide line used for alignment — either infinite or finite depending on how it was created.

Construction lines (guide lines) are visual aids that help align geometry during modeling. Unlike edges, they don’t bound faces.

Create with a point + vector for an infinite line, or two points for a finite guide segment. Infinite lines have start and end set to null; finite lines have start and end at the two points you specified.

let model = await SketchUpApi.getActiveModel();
let { Point3d, Vector3d } = SketchUpApi;
await model.performOperation(op => {
// Infinite guide: point + vector
op.createConstructionLine(
model,
new Point3d(0, 0, 0),
new Vector3d(1, 0, 0)
);
// Finite guide: point + point
op.createConstructionLine(
model,
new Point3d(0, 50, 0),
new Point3d(100, 50, 0)
);
}, 'Create guides');
let lines = await model.entities.get({
filterBy: { types: ['ConstructionLine'] }
});
let infinite = lines[0];
let finite = lines[1];
console.log(infinite.start, infinite.end);
// => null null (infinite)
console.log(finite.start.toArray(), finite.end.toArray());
// => [0, 50, 0] [100, 50, 0]

SDK 2.7.0 Protocol 1.5.0

  • 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 direction: Vector3d

The unit direction vector of this infinite line. Combined with position, this fully defines the line’s orientation in 3D space.


readonly end: Point3d | null

The end point of a finite guide line, or null for infinite lines (created with point + vector).


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 construction line.


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 position: Point3d

Any point on the infinite line. This is typically the point you specified when creating the line, though SketchUp may adjust it.


readonly receivesShadows: boolean

Whether this element receives shadows cast by other geometry.

BaseDrawingElement.receivesShadows


readonly start: Point3d | null

The start point of a finite guide line, or null for infinite lines (created with point + vector).


readonly stipple: number

The line pattern style, encoded as a number. Solid lines are 0, while dashed and dotted patterns have positive values.


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: ConstructionLine = EntityType.ConstructionLine

get sketchupId(): SketchupId

JS API identifier for this construction line. 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


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<ConstructionLine>

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

Promise<ConstructionLine>

A new ConstructionLine reflecting the current model state. Throws if the construction line has been deleted.

let model = await SketchUpApi.getActiveModel();
let lines = await model.entities.get({
filterBy: { types: ['ConstructionLine'] },
});
// Later, after the user makes changes...
let fresh = await lines[0].refresh();
console.log(fresh.position.toArray());

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