Skip to content

Tag

A tag (formerly “layer”) that controls the visibility of drawing elements in the model.

Tags let users show or hide groups of geometry together — for example, tagging all furniture so it can be toggled on or off at once. Retrieve a tag by name with model.getTagManager().findTag(), or create new tags inside a performOperation with op.createTag().

let model = await SketchUpApi.getActiveModel();
// Create a tag and assign it a color
await model.performOperation(op => {
const ref = op.createTag('Furniture');
op.tagSetColor(
ref, new SketchUpApi.Color(76, 175, 80)
);
}, 'Create Furniture tag');
// Read it back
let tm = await model.getTagManager();
let tag = await tm.findTag('Furniture');
console.log(tag.name);
// => 'Furniture'
console.log(tag.color.toHex());
// => '#4CAF50FF'

readonly attributes: Attributes

User-defined key-value data attached to this tag.


readonly color: Color

The indicator color shown next to this tag in the Tags panel.


readonly folderRef: TagFolderRef | undefined

A reference to the folder this tag belongs to, or undefined if it is in the root.


readonly id: number

The persistent numeric identifier for this tag, stable across sessions.


readonly name: string

The user-visible name of this tag, like 'Furniture'.


readonly type: Tag = EntityType.Tag


readonly visible: boolean

Whether geometry assigned to this tag is currently visible.

get sketchupId(): SketchupId

JS API identifier for this tag. Pass it to API methods that accept a sketchupId.

SketchupId


get typeName(): string

Returns a named variant of the type field.

SDK 2.35.0

string

getFolder(): Promise<TagFolder | undefined>

Fetches the folder this tag belongs to, or undefined if the tag is in the root (not inside any folder).

Promise<TagFolder | undefined>

SDK 2.30.0


refresh(): Promise<Tag>

Re-fetches this tag from SketchUp to pick up any changes made since this snapshot was taken.

Promise<Tag>


toString(): string

string

readonly folderId: number | undefined

The persistent id of the parent TagFolder instance


get folder(): Promise<TagFolder | undefined>

Promise<TagFolder | undefined>