Element Tab

Messages may be sent and received by element tab application extensions. This is the menu option for + menu -> Add application inside a document . After menu click, a new tab will be created with the action url associated with this extension.

image alt text

Supported messages

The following messages can be sent by Element tab application extensions:

Message name (case sensitive)Additional propertiesNotes
applicationInitnotifyWhenSaveRequired: Whether Onshape should send a notification to save pending changes during certain operations. (default: false)Send once on application startup.
closeFlyoutsAndMenusSend when a mouse click or other event happens in the application extension. Closes Onshape flyouts and dropdown menus.
closeSelectItemDialogCloses the select item dialog.
connectionLostDisplays the standard Onshape connection lost message in a message bubble, forcing the user to either reload the document or return to the documents page.
errorReloadmessage: your messageSimilar to the connectionLost message, but enables an application to specify the first part of the message, which will be used instead of "Onshape is not connected." The user must reload the document or return to the documents page.
finishedSavingmessageId: the id sent in the corresponding saveChanges messageResponse to a saveChanges message sent from Onshape. Should be sent after application has cleaned up any pending edits.
keepAliveSend periodically while while the user is actively working to avoid the session from timing out.
saveAVersionSend when the user types Shift-S in the application extension, the keyboard shortcut for save a version.
showKeyboardShortcutsHelpSend when the user types ? (Shift-? on most keyboards) in the application extension, the keyboard shortcut for the keyboard shortcuts help dialog.
showMessageBubblemessage: your messageSend when you want to show a string in the message bubble at the top of the Onshape app.
startLoadingSpinnermessage: your messageSend to start a large spinner in the middle of the browser window with your message underneath it.
stopLoadingSpinnerSend to stop the large spinner.
startWorkingSpinnerSend to start a small spinner in the middle bottom of the browser window.
stopWorkingSpinnerSend to stop the small spinner.
openSelectItemDialog
  • dialogTitle: your dialog title (default="")
  • selectBlobs: true or false (default)
  • selectParts: true or false (default)
  • selectPartStudios: true or false (default)
  • selectAssemblies: true or false (default)
  • selectMultiple: true or false (default)
  • selectBlobMimeTypes: comma-delimited string of blob mime types to show in dialog (e.g. “application/dwt,application/dwg”); (default="")
  • showBrowseDocuments: Whether "Other documents" choice should be available (default=true)
  • showStandardContent: Whether "Standard content" choice should be available (default=false)
Send when your application wants to open a dialog in which the user will select one or multiple items - blobs, parts, part studios or assemblies.
requestCameraPropertiesgraphicsElementId: string, element ID of the part studio or assemblySend to request camera properties of a specific part studio or assembly element. Note: The element should have been opened at least once in the current session. The messageName of the response is cameraProperties.

Received messages

The following messages can be received by Element tab application extensions:

Message name (case sensitive)Additional propertiesNotes
showSent when an element tab application extension is shown (made active) within the Onshape client. This message is NOT sent when the element tab application extension is created.
hideSent when an element tab application extension is made inactive within the Onshape client. This message is NOT sent when an element tab application extension is deleted.
itemSelectedInSelectItemDialog
  • documentId: ID of selected item’s document
  • workspaceId: ID of selected item’s workspace; empty if versionId is not empty.
  • versionId: ID of selected item’s version; empty if workspaceId is not empty.
  • elementId: ID of element selected or containing the selected part.
  • elementName: Name of element selected or containing the selected part.
  • elementType: Type of element selected or containing the selected part partstudio | assembly | blob
  • elementMicroversionId: Microversion id of the element
  • itemType: Type of item selected: part | partStudio | assembly
  • partName: Name of part selected; empty if itemType is not part
  • idTag: ID of part; empty if no part is selected.
Sent when the user selects an item (blob, part, part studio or assembly) in the select item dialog that was opened due to an openSelectItemDialog message sent earlier. When a part is not selected, the partXxx message properties will be empty strings.
printSent when the user chooses the Print command while the application is the active element. The application can choose to handle this as either a print or an export to a PDF or other format.
selectItemDialogClosedSent when the select item dialog closes, either because the user selected an item and selectMultiple is false, or the user changed the active element or the user closed the dialog with the "X" button.
startFirstViewCommand
  • documentId: ID of selected item’s document
  • workspaceId: ID of selected item’s workspace; empty if versionId is not empty.
  • versionId: ID of selected item’s version; empty if workspaceId is not empty.
  • elementId: ID of element selected or containing the selected part.
  • elementName: Name of element selected or containing the selected part.
  • elementType: Type of element selected or containing the selected part partstudio | assembly | blob
  • elementMicroversionId: Microversion id of the element
  • itemType: Type of item selected: part | partStudio | assembly
  • partName: Name of part selected; empty if itemType is not part
  • idTag: ID of part; empty if no part is selected.
Sent to a drawings application extension when the drawing is created with zero views.
export
  • fileExtension: the file extension of the export type the user chose: .dwg | .dxf
  • baseFileName: the base portion of the expected output file. Default: “{documentName} - {elementName}”
Sent when the user chooses a command to export the contents of the application to a file.
cameraProperties
  • graphicsElementId: string; Element ID of the part studio or assembly
  • isValid: boolean; Indicates if the properties are valid or not. false if element ID is invalid or element has not been open in the current session
  • projectionType: string; Denotes the projection method. Values are ‘orthographic’, ‘perspective’ . Empty string ‘’ if isValid is false
  • viewMatrix: 16 element numeric matrix with elements at index 13, 14, 15 corresponding to position of the camera
  • projectionMatrix: 16 element numeric matrix
  • verticalFieldOfView: number; 0 in case of orthographic projection
  • viewportHeight: number; height of the viewport
  • viewportWidth: number; width of the viewport
Sent when application posts a requestCameraProperties message
takeFocusSent when the Onshape client sets focus on the content window of the element tab application extension.
saveChangesmessageId: a unique identifier for this message. Should be passed back in the finishedSaving message.Sent if the application specified notifyWhenSaveRequired in the applicationInit message. Indicates that the application should cleanup any pending edits before an Onshape process continues (i.e. version save).

Security considerations

All Security Considerations apply to all Onshape extensions, with the following notes:

  • Initial message from the application extension to the Onshape client, in the form of an applicationInit message (or one of any other messages supported by the element right panel extensions), is required to ensure the Onshape client does not send messages to the extension until it is ready.
  • Once a valid applicationInit message is received by the Onshape client, it will start sending messages with the messageName value SELECTION upon user selection interactions.
  • Prior to accepting any message from the Onshape client as secure, the origin attribute value included in incoming messages must be validated as equal to the original server query parameter value used to load the application extension.