AttachmentAPI¶
Interface AttachmentAPI
createAttachment(dataType: AttachmentType): number;
fetchAttachmentData(attachmentID: number): Promise<Serializable>;
getAttachmentData(attachmentID: number): Serializable;
getAttachmentDataURI(attachmentID: number): string;
removeAttachment(attachmentID: number, safe?: boolean): RemoveState;
setAttachmentData(attachmentID: number, data: Serializable): void;
setAttachmentDataURI(attachmentID: number, dataURI: string): void;
}
Hierarchy (View Summary)
- AttachmentAPI
Methods
create Attachment
Creates a new attachment.
Triggers an AttachmentCreatedEvent.
Parameters
- dataType: AttachmentType
Specifies the attachment data type.
Returns number
The ID of the created attachment.
- dataType: AttachmentType
fetch Attachment Data
Fetches and returns the attachment data of the specified attachment.
Parameters
- attachmentID: number
Specifies the attachment object.
Returns Promise<Serializable>
The attached data.
- attachmentID: number
get Attachment Data
Returns the attachment data.
Parameters
- attachmentID: number
Specifies the attachment object.
Returns Serializable
The attached data
Deprecated
getAttachmentData is deprecated, please use fetchAttachmentData instead.
- attachmentID: number
get Attachment Data URI
Returns the attachment data URI.
Parameters
- attachmentID: number
Specifies the attachment object.
Returns string
The attachment data URI.
- attachmentID: number
remove Attachment
Removes the Attachment from the scene and all related snapshots.
Triggers an AttachmentRemovedEvent.
Parameters
- attachmentID: number
Specifies the attachment object.
Optionalsafe: booleanPerforms a safe remove which interrupt the removal process if the attachment is part of one or more snapshots. If no safe remove, a snapshot could link to missing data. Default: false.
Returns RemoveState
The state of the removal process.
- attachmentID: number
set Attachment Data
Sets the attachment data.
Triggers an AttachmentDataChangedEvent.
Parameters
- attachmentID: number
Specifies the attachment object.
- data: Serializable
The new attachment data.
Returns void
- attachmentID: number
set Attachment Data URI
Sets the attachment data URI.
Parameters
- attachmentID: number
Specifies the attachment object.
- dataURI: string
The attachment data URI.
Returns void
- attachmentID: number
webvis: The AttachmentAPI
Overview
The AttachmentAPI provides basic functionalities to define additional data optionally attached to a node. This data can be of any type defined in AttachmentType and is stored in the form of a URI. The AttachmentAPI provides methods to fetch, set and remove the data.
Quick Start
Example: Create a new attachment with text data.
Adding Attachments to nodes
Attachments can be added to nodes using the setProperty method.
Example: attaching an attachment to a node.
Events
The following events are associated with the AttachmentAPI: