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.
Example
Section titled “Example”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
Extends
Section titled “Extends”BaseDrawingElement
Properties
Section titled “Properties”attributes
Section titled “attributes”
readonlyattributes:Attributes
The attribute dictionaries attached to this element. Attributes store custom key-value metadata that extensions can read and write.
Inherited from
Section titled “Inherited from”BaseDrawingElement.attributes
castsShadows
Section titled “castsShadows”
readonlycastsShadows:boolean
Whether this element casts shadows onto other geometry.
Inherited from
Section titled “Inherited from”BaseDrawingElement.castsShadows
direction
Section titled “direction”
readonlydirection:Vector3d
The unit direction vector of this infinite line. Combined with position,
this fully defines the line’s orientation in 3D space.
readonlyend:Point3d|null
The end point of a finite guide line, or null for
infinite lines (created with point + vector).
hidden
Section titled “hidden”
readonlyhidden:boolean
Whether this element is hidden. Hidden elements don’t appear in the viewport unless the user enables “View > Hidden Geometry.”
Inherited from
Section titled “Inherited from”BaseDrawingElement.hidden
readonlyid:number
The persistent ID that uniquely identifies this construction line.
materialRef
Section titled “materialRef”
readonlymaterialRef: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.
Inherited from
Section titled “Inherited from”BaseDrawingElement.materialRef
position
Section titled “position”
readonlyposition:Point3d
Any point on the infinite line. This is typically the point you specified when creating the line, though SketchUp may adjust it.
receivesShadows
Section titled “receivesShadows”
readonlyreceivesShadows:boolean
Whether this element receives shadows cast by other geometry.
Inherited from
Section titled “Inherited from”BaseDrawingElement.receivesShadows
readonlystart:Point3d|null
The start point of a finite guide line, or null for
infinite lines (created with point + vector).
stipple
Section titled “stipple”
readonlystipple:number
The line pattern style, encoded as a number. Solid lines are 0, while
dashed and dotted patterns have positive values.
tagRef
Section titled “tagRef”
readonlytagRef:TagRef|undefined
A reference to the tag (formerly “layer”) assigned to this element. Call
getTag() to fetch the full Tag object.
Inherited from
Section titled “Inherited from”BaseDrawingElement.tagRef
readonlytype:ConstructionLine=EntityType.ConstructionLine
Accessors
Section titled “Accessors”sketchupId
Section titled “sketchupId”Get Signature
Section titled “Get Signature”get sketchupId():
SketchupId
JS API identifier for this construction line. Pass it to API methods that accept a sketchupId.
Returns
Section titled “Returns”Overrides
Section titled “Overrides”BaseDrawingElement.sketchupId
typeName
Section titled “typeName”Get Signature
Section titled “Get Signature”get typeName():
string
Returns a named variant of the type field.
SDK 2.35.0
Returns
Section titled “Returns”string
Methods
Section titled “Methods”getBounds()
Section titled “getBounds()”getBounds():
Promise<BoundingBox>
Fetches the axis-aligned bounding box for this element from SketchUp.
Returns
Section titled “Returns”Promise<BoundingBox>
Example
Section titled “Example”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
Inherited from
Section titled “Inherited from”BaseDrawingElement.getBounds
getMaterial()
Section titled “getMaterial()”getMaterial():
Promise<Material|undefined>
Fetches the material applied to this element. Returns undefined if the
element uses the default material.
Returns
Section titled “Returns”Promise<Material | undefined>
Example
Section titled “Example”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
Inherited from
Section titled “Inherited from”BaseDrawingElement.getMaterial
getTag()
Section titled “getTag()”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.
Returns
Section titled “Returns”Promise<Tag | undefined>
Example
Section titled “Example”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
Inherited from
Section titled “Inherited from”BaseDrawingElement.getTag
refresh()
Section titled “refresh()”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.
Returns
Section titled “Returns”Promise<ConstructionLine>
A new ConstructionLine reflecting the current model state. Throws if the construction line has been deleted.
Example
Section titled “Example”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()
Section titled “toString()”toString():
string
Returns a string representation of an object.
Returns
Section titled “Returns”string
Deprecated
Section titled “Deprecated”materialId
Section titled “materialId”
readonlymaterialId:number|undefined
Inherited from
Section titled “Inherited from”BaseDrawingElement.materialId
readonlytagId:number|undefined
Inherited from
Section titled “Inherited from”BaseDrawingElement.tagId
bounds
Section titled “bounds”Get Signature
Section titled “Get Signature”get bounds():
Promise<BoundingBox>
Returns
Section titled “Returns”Promise<BoundingBox>
Inherited from
Section titled “Inherited from”BaseDrawingElement.bounds
Get Signature
Section titled “Get Signature”get tag():
Promise<Readonly<Tag> |undefined>
Returns
Section titled “Returns”Promise<Readonly<Tag> | undefined>
Inherited from
Section titled “Inherited from”BaseDrawingElement.tag