Skip to content

Entities

The gateway to querying drawing elements owned by a container.

Every container — the root model, a group, or a component definition — exposes an .entities property which is an Entities instance. Use it to fetch drawing elements like edges, faces, groups, and more. You can retrieve everything or filter by type.

let model = await SketchUpApi.getActiveModel();
// Get all entities in the model root
let all = await model.entities.get();
// Filter by type
let faces = await model.entities.get({
filterBy: { types: ['Face'] }
});
// Get curves and arc-curves
let curves = await model.entities.getCurves();

SDK 2.29.0

readonly parent: EntitiesContainer | EntitiesContainerRef

The container (model, group, or component definition) that owns these entities.

get<Filter>(options?): Promise<EntityTypeForFilter<Filter, DrawingElement>[]>

Fetches all drawing elements owned by this container. Without a filter, returns every edge, face, group, component instance, and more. Use filterBy to narrow by entity type.

Type Parameter Default type

Filter extends EntityFilter

EntityFilter

Parameter Type

options?

EntityQuery<Filter>

Promise<EntityTypeForFilter<Filter, DrawingElement>[]>

let model = await SketchUpApi.getActiveModel();
// Get all entities
let all = await model.entities.get();
// Get only faces
let faces = await model.entities.get({
filterBy: { types: ['Face'] }
});
// Get entities inside a group
let groups = await model.entities.get({
filterBy: { types: ['Group'] }
});
let edges = await groups[0].entities.get({
filterBy: { types: ['Edge'] }
});

getActiveSectionPlane(): Promise<SectionPlane | undefined>

Fetches the currently active section plane for this container, if one exists. Section planes cut through the model to reveal interior geometry. Returns undefined if no section plane is active.

Promise<SectionPlane | undefined>

let model = await SketchUpApi.getActiveModel();
let plane =
await model.entities.getActiveSectionPlane();
if (plane) {
console.log('Active section plane found');
}

SectionPlane

SDK 2.16.0 Protocol 1.13.0


getCurves<Filter>(options?): Promise<EntityTypeForFilter<Filter, ArcCurve | Curve>[]>

Fetches all curves and arc-curves owned by this container. Returns an empty array if the SketchUp version does not support curve queries. Curves are collections of edges that form continuous arcs or polylines.

Type Parameter Default type

Filter extends EntityFilter

EntityFilter

Parameter Type

options?

EntityQuery<Filter>

Promise<EntityTypeForFilter<Filter, ArcCurve | Curve>[]>

let model = await SketchUpApi.getActiveModel();
let curves = await model.entities.getCurves();
for (const curve of curves) {
console.log(curve.edges.length);
}

SDK 2.23.0 Protocol 1.20.0


toString(): string

string