Skip to content

CRSLocation

The Coordinate Reference System (CRS) that maps SketchUp model coordinates to real-world geographic coordinates.

A CRS defines the origin, orientation, and scale relationship between the SketchUp coordinate system (in inches) and a projected map coordinate system like UK OS National Grid or UTM. Construct one and pass it to op.modelSetCRSLocation(), or read the current one with model.getCRSLocation().

Use localToWorld() to convert SketchUp points to map coordinates, and worldToLocal() to do the reverse.

// Define a CRS for UK OS National Grid
let crs = new SketchUpApi.CRSLocation({
name: 'EPSG:27700',
eastings: 530000,
northings: 180000,
height: 0,
scale: SketchUpApi.CRSScale.Meters,
});
// Convert model origin to world coordinates
let world = crs.localToWorld(
new SketchUpApi.Point3d(0, 0, 0)
);
console.log(world.easting);
// => 530000
console.log(world.northing);
// => 180000

SDK 2.28.0

new CRSLocation(crsData): CRSLocation

Parameter Type

crsData

MinimalCRSLocationData

CRSLocation

readonly optional calibrationFileName?: string

Optional metadata that should be set IF the CRS was defined from a calibration file.

Calibration files are typically either .jxl or .dc files.

CRSLocationData.calibrationFileName


readonly optional description?: string

The description of the coordinate reference system.

This should not be parsed in any meaningful way.

CRSLocationData.description


readonly eastings: number

The offset in the “X” direction from the CRS center to the origin of the SketchUp model

CRSLocationData.eastings


readonly optional geodeticDatum?: string

Optional string that identifies the geodetic datum for the CRS. Typically only defined if the “name” field is not specific enough

CRSLocationData.geodeticDatum


readonly height: number

The offset from “0” in the “Z” direction at the origin of the SketchUp model

CRSLocationData.height


readonly optional mapProjection?: string

Optional string that identifies the map projection used by the CRS. Typically only defined if the “name” field is not specific enough

CRSLocationData.mapProjection


readonly optional mapUnit?: MapUnit

Optional unit for the CRS

If not defined, Meters is assumed. When overriding this value, make sure to set the appropriate value for scale.

CRSLocationData.mapUnit


readonly optional mapZone?: string

Optional string that identifies the map zone used by the CRS. Typically only defined if the “name” field is not specific enough

CRSLocationData.mapZone


readonly name: string

The name of the coordinate reference system being used.

It is convention for this to reference an EPSG code in the form “EPSG:27700”

CRSLocationData.name


readonly northings: number

The offset in the “Y” direction from the CRS center to the origin of the SketchUp model

CRSLocationData.northings


readonly scale: number

Represents the conversion between the units of the SketchUp coordinate system (inches) and the units of the CRS.

If not present, the scale will be determined based on the map unit If the map unit is not present, it is assumed to be Meters and this will default to

CRSLocationData.scale


readonly optional tglID?: string

If present - the Trimble Geodetic Library encoding of the CRS This can be used to perform conversions between the CRS and WGS84

CRSLocationData.tglID


readonly optional verticalDatum?: string

Optional string that identifies the map zone used by the CRS. Typically only defined if the “name” field is not specific enough

CRSLocationData.verticalDatum


readonly xAxis: Vector2d

The direction vector of the xAxis as projected on the 2d plane of the CRS

The x value represents the xAxisAbscissa from the IFC spec The y value represents the xAxisOrdinate from the IFC spec

If not present the vector [1, 0] is assumed

CRSLocationData.xAxis

localToWorld(suPoint): CRSPoint

Converts a SketchUp model point to world CRS coordinates, applying the rotation, scale, and origin offset defined by this CRS.

Parameter Type Description

suPoint

Point3d

the point in SketchUp model coordinates

CRSPoint

the corresponding CRSPoint in world coordinates


toString(): string

Returns a string representation of an object.

string


worldToLocal(worldPoint): Point3d

Converts a world CRS coordinate to a local SketchUp point, applying the rotation, scale, and origin offset defined by this CRS.

Parameter Type Description

worldPoint

CRSPoint

the point in CRS world coordinates

Point3d

the corresponding point in SketchUp model coordinates