Point3d
A position in 3D space, measured in inches.
Point3d is the fundamental coordinate type in the SketchUp
API. Every vertex, construction point, and camera position is
ultimately a Point3d. Coordinates are always in inches —
SketchUp’s internal unit — regardless of what display units
the model is configured to show.
Points are immutable: methods like add() and subtract()
return new instances rather than modifying the original.
Example
Section titled “Example”let { Point3d } = SketchUpApi;
let a = new Point3d(10, 20, 0);let b = new Point3d(40, 60, 0);
console.log(a.distance(b));// => 50 (inches)
// Offset a point by a vectorlet moved = a.add([5, 5, 10]);console.log(moved.toArray());// => [15, 25, 10]
// Compare with tolerancelet c = new Point3d(10.0005, 20, 0);console.log(a.equalTo(c));// => true (within default 0.001" tolerance)Constructor
Section titled “Constructor”Constructor
Section titled “Constructor”new Point3d(
x?,y?,z?):Point3d
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”Point3d
Properties
Section titled “Properties”
readonlyx:number=0
readonlyy:number=0
readonlyz:number=0
Methods
Section titled “Methods”add(
input):Point3d
Returns a new point offset by the given vector or array. Does not modify this point.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
Returns
Section titled “Returns”Point3d
Example
Section titled “Example”let { Point3d } = SketchUpApi;let a = new Point3d(1, 2, 3);let b = new Point3d(10, 20, 30);
// Point3d(11,22,33);console.log(a.add(b).toString());distance()
Section titled “distance()”distance(
point):number
The straight-line distance to another point, in inches.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
Returns
Section titled “Returns”number
Example
Section titled “Example”let { Point3d } = SketchUpApi;let a = new Point3d(1, 2, 3);let b = new Point3d(10, 20, 30);
// ~33.67console.log(a.distance(b));distanceToLine()
Section titled “distanceToLine()”distanceToLine(
ray):number
Calculates the closest distance between this point and the given line (ray)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
Returns
Section titled “Returns”number
Example
Section titled “Example”let { Point3d } = SketchUpApi;let a = new Point3d(1,2,3);let b = new Point3d(4,5,6);let c = new Point3d(7,8,9);
// 0console.log(c.distanceToLine([a, b]));SDK 2.37.0
distanceToPlane()
Section titled “distanceToPlane()”distanceToPlane(
plane):number
Calculates the closest distance between this point and the given plane.
NOTE The distance is unsigned, it cannot tell you if the value is above or below the plane
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
Returns
Section titled “Returns”number
Example
Section titled “Example”let { Point3d } = SketchUpApi;let a = new Point3d(1,2,3);
// 2console.log(a.distanceToPlane([0, 0, 1, -5]));SDK 2.37.0
equalTo()
Section titled “equalTo()”equalTo(
point,tol?):boolean
Compares two points component-wise within a tolerance. The default tolerance is 0.001” — close enough for SketchUp’s internal precision.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
|
|
|
|
‐ |
|
|
|
|
per-axis tolerance in inches, defaults to 0.001 |
Returns
Section titled “Returns”boolean
Example
Section titled “Example”let { Point3d } = SketchUpApi;let a = new Point3d(1, 2, 3);
// trueconsole.log(a.equalTo(a.add([0.0009,0,0])));// falseconsole.log(a.equalTo(a.add([0.001,0,0])));isOnLine()
Section titled “isOnLine()”isOnLine(
ray,tolerance?):boolean
Returns true if point is on the given line (ray) within a supplied tolerance.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
|
|
|
|
the ray |
|
|
|
|
defaults to 0.001 |
Returns
Section titled “Returns”boolean
Example
Section titled “Example”let { Point3d } = SketchUpApi;let a = new Point3d(1,2,3);let b = new Point3d(4,5,6);let c = new Point3d(7,8,9);
// trueconsole.log(c.isOnLine([a, b]));SDK 2.37.0
isOnPlane()
Section titled “isOnPlane()”isOnPlane(
plane,tolerance?):boolean
Returns true if this point sits on the given plane within the tolerance in inches.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
|
|
|
|
‐ |
|
|
|
|
defaults to 0.001 |
Returns
Section titled “Returns”boolean
Example
Section titled “Example”let { Point3d } = SketchUpApi;let a = new Point3d(1,2,3);
// falseconsole.log(a.isOnPlane([0, 0, 1, -5]));// trueconsole.log(a.isOnPlane([0, 0, 1, -3]));SDK 2.37.0
offset()
Section titled “offset()”offset(
input,distance?):Point3d
Creates a new point using the given offset and distance
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
|
|
|
the distance along the vector to move the new point. When not supplied, the length of the vector is assumed to be the distance. |
Returns
Section titled “Returns”Point3d
Point3d
Example
Section titled “Example”let { Point3d } = SketchUpApi;let a = new Point3d(1,2,3);// Vector3d(101,2,3)console.log(a.offset([100,0,0]).toString());// Vector3d(-9,2,3)console.log(a.offset([100,0,0],-10).toString());SDK 2.37.0
projectToLine()
Section titled “projectToLine()”projectToLine(
ray):Point3d
Returns the point along the line (ray) that is closest to this point.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
Returns
Section titled “Returns”Point3d
Example
Section titled “Example”let { Point3d } = SketchUpApi;let a = new Point3d(1,2,3);let b = new Point3d(4,5,6);let c = new Point3d(100,101,0);
// ~ Point3d(100,101,102)console.log(c.projectToLine([a, b]));SDK 2.37.0
projectToPlane()
Section titled “projectToPlane()”projectToPlane(
plane):Point3d
Returns the closest point to this point on the given plane.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
Returns
Section titled “Returns”Point3d
Example
Section titled “Example”let { Point3d } = SketchUpApi;let a = new Point3d(1,2,3);
// Point3d(1,2,5)console.log(a.projectToPlane([0, 0, 1, -5]));SDK 2.37.0
signedDistanceToPlane()
Section titled “signedDistanceToPlane()”signedDistanceToPlane(
plane):number
Calculates the closest distance between this point and the given plane.
Returns a positive value if the point is “above” the plane, negative otherwise.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
Returns
Section titled “Returns”number
Example
Section titled “Example”let { Point3d } = SketchUpApi;let a = new Point3d(1,2,3);
// 2console.log(a.distanceToPlane([0, 0, 1, -5]));SDK 2.37.0
subtract()
Section titled “subtract()”subtract(
input):Point3d
Returns a new point shifted in the opposite direction of the given vector or array. Does not modify this point.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
Returns
Section titled “Returns”Point3d
Example
Section titled “Example”let { Point3d } = SketchUpApi;let a = new Point3d(1, 2, 3);let b = new Point3d(10, 20, 30);
// Point3d(-9,-18,-27);console.log(a.subtract(b).toString());toArray()
Section titled “toArray()”toArray(): [
number,number,number]
Returns this point as an [x, y, z] tuple — handy for
logging or passing to methods that accept arrays.
Returns
Section titled “Returns”[number, number, number]
SDK 2.35.0
toString()
Section titled “toString()”toString():
string
Returns
Section titled “Returns”string
toVector()
Section titled “toVector()”toVector():
Vector3d
Converts this point to a vector from the origin — same x, y, z values but interpreted as a direction/displacement.
Returns
Section titled “Returns”with()
Section titled “with()”with(
partialPoint):Point3d
Returns a new point with the defined values from the partialPoint replacing this point.
Null and undefined values are ignored.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
Returns
Section titled “Returns”Point3d
Example
Section titled “Example”let { Point3d } = SketchUpApi;let a = new Point3d(1,2,3);let b = a.with({z: 0});// Point3d(1,2,0)console.log(b.toString());SDK 2.37.0
create()
Section titled “create()”
staticcreate(input):Point3d
Converts a Point3Like into a Point3d instance. If
you already have a Point3d, it’s returned as-is. Useful
when writing your own functions that accept a Point3Like
and need a concrete Point3d to call methods on.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
anything shaped like a Point3d |
Returns
Section titled “Returns”Point3d
Example
Section titled “Example”let { Point3d } = SketchUpApi;
let fromArray = Point3d.fromPoint3Like([10, 20, 0]);console.log(fromArray.toArray());// => [10, 20, 0]
let p = new Point3d(5, 5, 5);console.log(Point3d.fromPoint3Like(p) === p);// => true (already a Point3d, returned as-is)SDK 2.37.0
fromLinearCombination()
Section titled “fromLinearCombination()”
staticfromLinearCombination(w1,p1,w2,p2):Point3d
Combines two points using weighted coefficients:
w1 * p1 + w2 * p2. Commonly used to interpolate between
two points — for example, the midpoint is
fromLinearCombination(0.5, p1, 0.5, p2) — though the
weights don’t need to sum to 1.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
weight applied to |
|
|
|
the first point |
|
|
|
weight applied to |
|
|
|
the second point |
Returns
Section titled “Returns”Point3d
Example
Section titled “Example”let { Point3d } = SketchUpApi;
// Midpoint between a and blet mid = Point3d.fromLinearCombination( 0.5, [0, 0, 0], 0.5, [10, 20, 0]);console.log(mid.toArray());// => [5, 10, 0]Deprecated
Section titled “Deprecated”Get Signature
Section titled “Get Signature”get to_a(): [
number,number,number]
Returns
Section titled “Returns”[number, number, number]
fromPoint2Like()
Section titled “fromPoint2Like()”
staticfromPoint2Like(input):Point3d
Creates a Point3d from an [x, y] tuple, with z set to
0. Useful for 2D contexts — like screen coordinates or a
flat sketch — where a Z coordinate doesn’t apply.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
[ |
an |
Returns
Section titled “Returns”Point3d
Example
Section titled “Example”let { Point3d } = SketchUpApi;
let p = Point3d.fromPoint2Like([10, 20]);console.log(p.toArray());// => [10, 20, 0]fromPoint3Like()
Section titled “fromPoint3Like()”
staticfromPoint3Like(input):Point3d
Converts a Point3Like into a Point3d instance. If
you already have a Point3d, it’s returned as-is. Useful
when writing your own functions that accept a Point3Like
and need a concrete Point3d to call methods on.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
anything shaped like a Point3d |
Returns
Section titled “Returns”Point3d
Example
Section titled “Example”let { Point3d } = SketchUpApi;
let fromArray = Point3d.fromPoint3Like([10, 20, 0]);console.log(fromArray.toArray());// => [10, 20, 0]
let p = new Point3d(5, 5, 5);console.log(Point3d.fromPoint3Like(p) === p);// => true (already a Point3d, returned as-is)