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().
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();
// Create a tag and assign it a colorawait model.performOperation(op => { const ref = op.createTag('Furniture'); op.tagSetColor( ref, new SketchUpApi.Color(76, 175, 80) );}, 'Create Furniture tag');
// Read it backlet tm = await model.getTagManager();let tag = await tm.findTag('Furniture');console.log(tag.name);// => 'Furniture'console.log(tag.color.toHex());// => '#4CAF50FF'Properties
Section titled “Properties”attributes
Section titled “attributes”
readonlyattributes:Attributes
User-defined key-value data attached to this tag.
readonlycolor:Color
The indicator color shown next to this tag in the Tags panel.
folderRef
Section titled “folderRef”
readonlyfolderRef:TagFolderRef|undefined
A reference to the folder this tag belongs to, or
undefined if it is in the root.
readonlyid:number
The persistent numeric identifier for this tag, stable across sessions.
readonlyname:string
The user-visible name of this tag, like 'Furniture'.
readonlytype:Tag=EntityType.Tag
visible
Section titled “visible”
readonlyvisible:boolean
Whether geometry assigned to this tag is currently visible.
Accessors
Section titled “Accessors”sketchupId
Section titled “sketchupId”Get Signature
Section titled “Get Signature”get sketchupId():
SketchupId
JS API identifier for this tag. Pass it to API methods that accept a sketchupId.
Returns
Section titled “Returns”typeName
Section titled “typeName”Get Signature
Section titled “Get Signature”get typeName():
string
Returns a named variant of the type field.
SDK 2.35.0
Returns
Section titled “Returns”string
Methods
Section titled “Methods”getFolder()
Section titled “getFolder()”getFolder():
Promise<TagFolder|undefined>
Fetches the folder this tag belongs to, or undefined if
the tag is in the root (not inside any folder).
Returns
Section titled “Returns”Promise<TagFolder | undefined>
SDK 2.30.0
refresh()
Section titled “refresh()”refresh():
Promise<Tag>
Re-fetches this tag from SketchUp to pick up any changes made since this snapshot was taken.
Returns
Section titled “Returns”Promise<Tag>
toString()
Section titled “toString()”toString():
string
Returns
Section titled “Returns”string
Deprecated
Section titled “Deprecated”folderId
Section titled “folderId”
readonlyfolderId:number|undefined
The persistent id of the parent TagFolder instance
folder
Section titled “folder”Get Signature
Section titled “Get Signature”get folder():
Promise<TagFolder|undefined>
Returns
Section titled “Returns”Promise<TagFolder | undefined>