Autodesk.Viewing.ViewingApplication
new ViewingApplication(containerId,options)
Wrapper application for the viewer component.
Attaches ViewingApplication to a div by ID and initializes common properties of the viewing application.
Parameters
containerId* string | The ID of the main container. |
options object | An optional dictionary of options. |
disableBrowserContextMenu boolean | Disables the browser’s default context menu. |
Methods
addItemSelectedObserver(observer)
Adds objects to be notified when a new item is selected in the browser tree.
Parameters
observer* object | Should implement function
onItemSelected(viewer) . |
finish()
Performs any necessary cleanup to allow the object to be garbage collected.
getCurrentViewer()
Returns the currently set Viewer.
Returns
Type | Description |
---|---|
Viewer3D |
getDefaultGeometry(geometryItems)
Given a list of geometry items, possibly fetched through Autodesk.Viewing.Document.getSubItemsWithProperties, it will return 1 single item from the list that should be the first one to be loaded. The method will attempt to find the item marked with attribute ‘useAsDefault’ with true. When none is found, it will return the first element from the list.
Parameters
geometryItems* array |
Returns
Type | Description |
---|---|
object | Item element contained in geometryItems. |
getNamedViews(item)
Returns a list of named views for the Viewer. It will use getSelectedItem() or the item parameter, if available.
Users may call into setlectItem() with a value of the returned array.
Available from version 2.15
Parameters
item object | The item for which you want to get named views |
Returns
Type | Description |
---|---|
array |
|
getSelectedItem()
Returns the node object containing metadata associated to the model currently loaded in the viewer.
Returns
Type | Description |
---|---|
null|object |
getViewer(config)
Returns a new instance of a Viewer of requested type.
Parameters
config* object | Viewer configuration override. |
Returns
Type | Description |
---|---|
Viewer3D | Viewer instance or null. |
getViewerContainer()
Returns the container that will be used by the viewer. By default uses the same container as the appContainer. This method can be overridden to specify a different sub container for the viewer.
Returns
Type | Description |
---|---|
MemberExpression |
loadDocument(documentId,onDocumentLoad,onLoadFailed,accessControlProperties)
Asynchronously loads a document (BubbleNode) given its ID. You can initialize a ViewingApplication with an already downloaded document using setDocument().
Parameters
documentId* * | Viewable document ID. |
onDocumentLoad function | Called on success. |
onLoadFailed function | Called on error. |
accessControlProperties object | An optional list of key value pairs as access control properties, which includes a list of access control header name and values, and an OAuth 2.0 access token. |
onDocumentFailedToLoad(errorCode,errorMsg,errors)
Default success callback for documentFailedToLoad. Logs the document that was loaded on console.
Parameters
errorCode* string | Globalized error code. |
errorMsg* string | Error message to display. |
errors* array | List of errors that come from other clients (translators). |
onDocumentLoaded(document)
Default success callback for loadDocument. Logs the document that was loaded on console.
Parameters
document* * |
onItemSelected(item,viewGeometryItem)
Called when selectItem successfully loads an item.
Parameters
item* object | Can be either type ‘view’ or ‘geometry’. |
viewGeometryItem* object | Can only be type ‘geometry’. Will be the same as item if item is type ‘geometry’. |
registerViewer(viewableType,viewerClass,config)
Register a Viewer to be used with this ViewingApplication.
Parameters
viewableType* number | Currently must be ViewingApplication.k3D. |
viewerClass* * | |
config* * |
selectItem(item,onSuccessCallback,onErrorCallback)
Asynchronously loads an individual item from a document into the correct viewer.
As of version version 2.15, parameter item may be a BubbleNode instead of a raw JavaScript object.
Parameters
item* * | |
onSuccessCallback* function | This call back is called when the item is selected. |
onErrorCallback* function | This call back is called when the item fails to select. |
Returns
Type | Description |
---|---|
boolean |
selectItemById(itemId,onItemSelectedCallback,onItemFailedToSelectCallback)
Finds the item within the current document and calls selectItem.
Parameters
itemId* number | |
onItemSelectedCallback function | This call back is called when the item is selected. |
onItemFailedToSelectCallback function | This call back is called when the item fails to select. |
Returns
Type | Description |
---|---|
boolean |
setCurrentViewer(viewer)
Sets this ViewingApplication’s viewer to the provided viewer.
Parameters
viewer* |
setDocument(docManifest)
Initializes the ViewingApplication with an already downloaded manifest that is Forge hosted. There is no need to call loadDocument() when this function is used.
Available from version 2.15
Parameters
docManifest* object | A JavaScript object for the hosted manifest. |
Returns
Type | Description |
---|---|
boolean | true if the document was successfully initialized, false if the document was not successfully initialized. |