Skip to content

TransformationLike

TransformationLike = Transformation | SketchupTransform | TransformationIdentity | TransformationScaleLike | TransformationTranslationLike

Any value that can be interpreted as a transformation.

Many API methods accept a TransformationLike so you can pass whichever representation is most convenient:

  • A Transformation instance
  • A 16-element number array (column-major 4x4 matrix)
  • null for the identity (no change)
  • A single number for uniform scaling
  • A Point3Like or Vector3Like for translation
let model = await SketchUpApi.getActiveModel();
let { Transformation } = SketchUpApi;
// ComponentInstance.transform accepts a
// TransformationLike, so all of these work:
let asInstance = Transformation.translation([10, 0, 0]);
let asArray = [0, 0, 0]; // translation shorthand
let asScale = 2; // uniform scale
let asNull = null; // identity (no-op)
// Read a group's current transform
let groups = await model.entities.get(
{ filterBy: { types: ['Group'] } }
);
if (groups.length > 0) {
console.log(groups[0].transform.origin.toArray());
}

Transformation