(no) Embedded Viewer API
Translation needed
The content of this page was copied from another page tree and needs to be translated or updated.
When you finish translation, make sure to
-
Replace the label NEEDS-TRANSLATING with TRANSLATED
-
Remove this macro from the page
Introduction
This article describes simple API that can be used on client side. The full server API is always available under https://<your-hdc-host>/apidocs
Running Viewer in "embedded" headless mode can be achived by adding viewport=EmbeddedViewer to HDC server call.
http://localhost:8080/client/?viewport=EmbeddedViewer
Your request must be pre-authenticated, otherwise it will be redirected to main login screen. After login, user might be redirected to full layout.
Controlling Toolbar Visibility
since handling of embedded mode must be reviewed (pre-authentication, navigating back, avoiding login screen or full app load),
a simple parameter was added to control toolbar visibility in embedded view:
?viewport=EmbeddedViewer&toolbar=true
when toolbar=true is added, all toolbars will be loaded (top, side panel and bottom status)
Query parameters for application initialization
Query Parameter | Values | Description |
---|---|---|
viewport |
| Changed main standard application viewport into embedded mode with limited UI. |
toolbar |
default: false | When set to true, all Viewer toolbars will be loaded (top, side panel and bottom statusbar) |
viewersidepanel |
| For backward compatibility, if a full toolbar is used, a side panel is always shown as well For simple toolbar, by default the sidepanel is hidden, unless a "viewer side panel" flag is used. |
gridview |
default: false | Creates split view with Grid and Viewer Grid View in embedded mode runs in a headless mode (no toolbar) and uses default perspective set to load data. To change the perspective set, please change a default assigned to your integration user. |
toolbarstyle |
default: full | |
viewerproperties | default value: unset Possible values:
| If this option is unset a user preferences will be used. If this option is set to any of the possible values, it will take priority over user settings. This parameter can be used in any application mode (embedded or not) |
syncback | possible values:
| When this parameter is given, it wil loverride user settings: When "on" - a sync back for selected spot to grid list will be always on. |
External and Internal Domains and Object Identification
The discussed API was designed to work both on HDC internal ID and external domain ID.
For more information, see
When data is imported or otherwise synchronized, external system can use GUID and object class known to it.
Lets take a look at a Rum object imported from IFC:
This object, as any other object would get it's HyperDoc ID (can be named differently or hidden depending on configuration).
The second field that is interesting to us is GUID. This field is indicated in a domain (EID) that we will use for this demo:
We will also need Domain ID that can be discovered on the main EID screen listing all domains:
The domain ID that we will use is 505
Why do I need to know domain ID?
Domains are used to identify different data sources. It can be any source or system, independently from data exchange format. By providing domain ID we indicate a "profile" that describes mapping of metadata fields,
fields used for identification, layer mapping etc. By indicating your domain ID, HDC will know what field names and what ID's does your system understand. In this way we can talk to many systems that understand different formats, field names or GUIDS that describe the same objects.
Another thing to note is how to identify HDC classes and their ID's. That can be done in an administrative panel, under Configuration → Object Classes
The internal Class ID for Rum is 108
API Methods
Using: showObject
To show the same Rum object we can use two equivalent calls:
/** * @method showObject Load given object view using InfoScope functionality.
* This will not work for content objects (documents)
* @param {objectId} * (required) HDID or TOBIS ID
* @param {classId} * (required)classId or class name from given domain
* @param {domain} * (optional) if provided, objectId is taken from TOBIS for * this domain */
showObject: function(objectId, classId, domain)
Call made with HDID (internal) and HDC Class: (see below API Methods for HD.EmbeddedApi.showObject function signature)
HD.EmbeddedApi.showObject('58307', '108');
This API will also accept Domain ID. In that case a call will be much simpler for external system, that does not know HDC class ID or internal object ID:
HD.EmbeddedApi.showObject('fe47162f-f8ee-4bed-8c4d-e30e1c5b25bf', 'fi2space', '505');
Parameters passed include GUID, class name according to your domain, and a domain ID. HDC will now translate this, using your domain profile into HDC object ID and class, and show the appropriate drawing.
the result will be a loaded drawing with our requested object marked and selected:
If the object does not have a spot representation, HDC will try to locate a default object (document) with similar rules as with HOPA "Document For Object" call.
HOPA perspective set in (no) Systeminnstillinger will be used to locate a default link (in most cases - a perspective that looks for linked documents)
Using: Show Multi Object
Since v4.1 with major changes in v4.6
Function: HD.EmbeddedApi.showMultiObject(gridObject, viewerObject, domain, viewPreference);
Grid Object or Viewer Object must be provided in the following form:
When domain ID is used, classId can also be your external class name.
Parameter | Type | Description |
---|---|---|
gridObject | Object | Optional object that will be used as "parent" object in GridView. It can be used as an only object argument - in such case a grid will load as this object would be selected in TreeView, exposing default document or object - that in turn will be visible in main Viewer. |
viewerObject | Object | Optional object to be loaded into Viewer This might be the only object argument in this call. Note - when this object is present it will:
|
domain | String/Number | |
viewPreference | Object | See viewPreference for showObject(); for base options For this function, when Grid View is enabled, additional parameter can be used:
|
Possible use cases for showMultiObject:
Parameter | Description |
---|---|
Grid Object: null | Grid Object is not given so it will not be loaded explicitly (It will be auto resolved in relation to Viewer object) |
Viewer Object | Viewer object is given. It's a Space object that will be loaded via InfoScope mode when spot link is present. Since InfoScope mode will be triggered, a Space tab should be selected in Grid. If you would like to have a document selected where the spot is located, use syncPreference: 'document' |
Domain ID: 523 | Domain Id is given, so Viewer Object will be looked up by using this domain config |
viewPreference |
|
Parameter | Description |
---|---|
Grid Object | Grid will be populated with child objects of this object according to perspective. Since we also have a space object, the space object will be preferred, and this object will be used as a preferred parent. |
Viewer Object | Viewer will attempt to show this object using basic resolving logic (for document via spot or default document) |
Domain ID: 523 | Domain used for Grid and Viewer object lookup. |
Parameter | Description |
---|---|
Grid Object | Grid will be populated with child objects of this object according to perspective. A default document/object will be selected and it will become an argument to Viewer. |
Viewer Object: null | Viewer will accept selected object in the Grid View. |
Domain ID: 523 | Domain used for Grid and Viewer object lookup. |
Using: Clear View
Since v4.1
Clear View
HD.EmbeddedApi.clearView();
Function used to clear the viewer content on demand.
Using: 3D View Preference parameter
'2D' or '3D' Parameter can be added to calls to indicate preferred view. Please note, that when the 3D view is not available for this object, it will not fall back to 2D automatically.
This parameter is optional and will only accept these two values. If it is not given or something else is passed, it will fallback to '2D' standard mode.
Sample:
HD.EmbededApi.showObject('47854', '130', null, '3D')
Events supported in 3D mode:
ui.docview.document.load - when the model is fully loaded and rendered.
ui.docview.document.ready
ui.model.user.spot.select - when the object is selected in the model.
Spot selected event for 3D model will result in the following payload:
External ID (or Entity ID) is the ID used by data provider (like Ocean server) to identify objects in the 3D Viewer domain. In this case this is a Revit GUID (UUID). It might be used directly or HDC classId and objectId can be used for conversion to any other domain.
Note: the 3D view is obtained on different rules then a standard HDC style view. For every given object a corresponding "level" must be identified. This is achieved by data query based on perspective. In that case we are not talking about a Drawing that has a spot on it, but rather objects grouped by Level. This group should contain out object (e.g. a Door, Window or Space). If a Building is given, then all Levels (Floors) will be used to load a full model.
Controlling zoom behavior
Since v4.0
Standard API call has the following parameters:
Now the last parameter can be either one of these:
2D - use standard view
3D - use 3D view if 3D viewing is configured
PC - use Point Cloud view when external system with this capability is configured. Note - this view will require proper object coordinates to be present in the system.
Or it can be an Object with additional parameters:
Parameter | possible values |
---|---|
mode |
Default value: 2D |
fitMode |
Default value: 0 Note: when Pan only mode is used, and object might not fit into view. Zoom will not be changed to accommodate new shape. |
fitMargin | Fit margin given as values between 0.1 (corresponds to 10%) and 5.0 (corresponds to 500%) If this parameter is not given a user parameter or system parameter is used. Only applicable when fitMode "0" is used. Default value is 50% margin. |
Sample objects:
Using: getSelectedObjects
/** * @method {getSelectedObjects}
Get array of selected objects For each* selected spot, find linked object and return it's ID.
* @param {domain} * domain that should be used to identify class ID. If domain
* is not given, the result is returned immediately but will * contain HD ID's. If Domain is specified, result must be
* returned in async callback.
* @param {callback} * a callback function that will be called when ID's are converted to specified domain
* @param {context} * a callback function context
*/
getSelectedObjects: function(domainId, callback, context)
Using this function will return ID and class information for all selected objects. It's important to know, that we actually select vector element that can be linked to many objects. It's not always simple 1:1 link.
The simples version of this call does not require any arguments:
With the above call we will get HDID + HDC Class that might not be suitable for external system. To change that, we need to provide additional parameters. In this case: domain ID: '505' and a callback function.
Call back function is needed, because the client viewer does not have full metadata information about selected objects. Based on given domain ID, we will make an asynchronous call to server for proper metadata.
When the conversion is done, function will be called with provided context and object data as a first argument.
Observe the success parameter. Data parameter will only contain objects information when success equals true. The returned data should have the following form:
From the external system point of view, the following parameters are interesting:
externalId: external ID, can be GUID or other indicated field
tobisFieldname: name of the field indicated as ID in external domain
externalClassname: class name as translated to indicated domain
If eidId is empty, it means that the selected object was found, but it does not contain this property.
Using: getSelectionMetrics
This method can be used to get area and length summary of selected elements on the drawing.
Several important remarks:
If viewer is in InfoScope mode (e.g not showing Document, but loaded with Room or Rental Unit context) selection will work for an Object, not drawing element.
That means ALL spots linked to this object will be selected automatically and the resulting area will be summarized.
If we have a database with three layers BRA, NTA and BTA spots from all layers will be taken into account. That might change when default link for spot is introduced, or area might be separated on per layer basis (not available today).
Using: applyFilter
This method can be used to apply filter to drawing. A filter ID must be known.
This call should be used in headless mode as it will not synchronize the filter selection dropdown. A legend will be shown if side panel is available.
See (no) Ad-hoc External Filters for custom filters.
Embedded API through Window.postMessage()
Since 2.7.0
See (no) Integration with 3rd party websites for more details.
Show Object - Object resolution logic
Show object is using a specific logic to resolve what should be shown in the viewer, based on passed object ID.
The passed object ID can be one of these:
Object with content (Document ID)
Object with attachment
Object with spot on one of the documents
Object with default document link
Object without a default link, but with one or more documents linked according to HOPA perspective
The logic can be summarized as follows:
if the object has "external" content, load this content
If the object has internal content (it's a document) or if it has a connected attachment, load it into view
If the object does not have any content, start the so called InfoScope mode:
try to find content for object by linked spot (e.g. room) or indirectly using Viewer perspective (e.g. Rental Unit)
if there are multiple content objects found, load first one and allow navigation between further elements (requires toolbar to be active)
If no content was found, check if default link is set to a document
If there is no default link to a document
get links to objects according to HOPA Document perspective
check if there are document type objects there
if there are objects there, try to find an object that matches preferred HOPA object class or related to that object class
if there are no preferred object classes, try to find first document object
load the found document object or quit (show blank view)