Request

Response

    Autodesk.Viewing.Extensions

    MarkupsCore

    new MarkupsCore(viewer, options)

    Extension that allows end users to draw 2D markups on top of 2D and 3D models.

    Parameters

    Expand all
    viewer*Viewer instance used to operate on.
    options*
    object
    Same Dictionary object passed into Viewer3D’s constructor.
    markupDisableHotkeys
    boolean
    Disables hotkeys for copy, cut, paste, duplicate, undo, redo and deselect.
    markupToolClassClass override for input handling. Use it to override/extend default hotkeys and/or mouse/gesture input.
    * Required

    Methods

    enterEditMode(layerId)

    Enables mouse interactions and mobile device gestures over the Viewer canvas to create or draw markups.

    Exit Edit mode by calling leaveEditMode().

    See also show()

    Parameters

    layerId*
    string
    [optional] Identifier for the layer of markups to be edited. Example “Layer1”.
    * Required

    Returns

    typedescription
    boolean Returns true if editMode is active

    leaveEditMode()

    Exits Edit mode.

    See also enterEditMode().

    Returns

    typedescription
    boolean Returns true if Edit mode has been deactivated

    toggle()

    Toggle between visible markups, i.e., show() and hidden markups, i.e., hide().

    show()

    Enables loading of previously saved markups. Exit Edit mode by calling hide().

    See also enterEditMode().

    Returns

    typedescription
    boolean Whether it successfully entered view mode or not.

    hide()

    Removes any markup currently overlaid on the viewer. It exits Edit mode if it is active.

    See also show()

    Returns

    typedescription
    boolean Whether it successfully left view mode or not.

    clear()

    Removes newly created markups in the current editing layer. Markups that were created in a specific layer will not be removed.

    Markups should have been added while in enterEditMode().

    generateData()

    Returns an SVG string with the markups created so far. The SVG string can be reloaded using loadMarkups().

    Markups should have been added while in enterEditMode().

    Returns

    typedescription
    string Returns an SVG element with all of the created markups in a string format.

    changeEditMode(editMode)

    Changes the active drawing tool. For example, from the Arrow drawing tool to the Rectangle drawing tool. Only applicable while in Edit Mode.

    Supported values are:

    • new Autodesk.Viewing.Extensions.Markups.Core.EditModeArrow(MarkupsCoreInstance)
    • new Autodesk.Viewing.Extensions.Markups.Core.EditModeRectangle(MarkupsCoreInstance)
    • new Autodesk.Viewing.Extensions.Markups.Core.EditModeCircle(MarkupsCoreInstance)
    • new Autodesk.Viewing.Extensions.Markups.Core.EditModeCloud(MarkupsCoreInstance)
    • new Autodesk.Viewing.Extensions.Markups.Core.EditModeText(MarkupsCoreInstance)
    • new Autodesk.Viewing.Extensions.Markups.Core.EditModeFreehand(MarkupsCoreInstance)
    • new Autodesk.Viewing.Extensions.Markups.Core.EditModePolyline(MarkupsCoreInstance)
    • new Autodesk.Viewing.Extensions.Markups.Core.EditModePolycloud(MarkupsCoreInstance)

    This function fires event Autodesk.Viewing.Extensions.MarkupsCore.EVENT_EDITMODE_CHANGED.

    Parameters

    editMode*
    object
    Object instance for the drawing tool
    * Required

    isNavigationAllowed()

    Check whether a user can perform camera navigation operations on the current loaded model. While the extension is active, the user can still draw markups. Panning and zooming are only supported for orthographic cameras.

    Returns

    typedescription
    boolean Whether allowNavigation() can succeed.

    allowNavigation(allow)

    Enables click, tap, and swipe behavior to allow camera zoom and panning operations. It is only available in Edit mode.

    Parameters

    allow*
    boolean
    Whether camera navigation interactions are active or not.
    * Required

    disableMarkupInteractions(disable)

    Sets mouse interactions and mobile device gestures with markups. Only applicable in Edit mode.

    Parameters

    disable*
    boolean
    true to disable interactions with markups; false to enable interactions with markups; default false.
    * Required

    copy()

    Standard copy operation. Applies to any selected markup. See also cut() and paste().

    cut()

    Standard cut operation. Applies to any selected markup, which gets removed from the screen at call time. See also copy() and paste().

    paste()

    Standard paste operation. This function will paste any previously copied or cut markup. Can be called repeatedly after a single copy or cut operation. See also copy() and cut().

    undo()

    Will undo the previous operation. The Undo/Redo stacks will track any change done to the existing markups. See also redo() and isUndoStackEmpty().

    redo()

    Will redo any previously undo operation. See also undo(), isRedoStackEmpty().

    isUndoStackEmpty()

    Returns true when undo() produces no changes.

    Returns

    typedescription
    boolean true if there are no changes to undo; false if there are changes to undo.

    isRedoStackEmpty()

    Returns true when redo() produces no changes.

    Returns

    typedescription
    boolean true if there are no changes to redo; false if there are changes to redo.

    getId()

    Helper function for generating unique markup ids.

    Returns

    typedescription
    number

    getMarkup(id)

    Returns a markup with the specified ID. Returns null when not found. The ID can be retrieved from the return value of getSelection(). See also getSelection().

    Parameters

    id*
    string
    Markup identifier.
    * Required

    Returns

    typedescription
    Autodesk.Viewing.Extensions.Markups.Core.Markup Returns markup object.

    selectMarkup(markup)

    Selects or deselects a markup. A selected markup gets an overlayed UI that allows you to perform transformations such as resizing, rotations, and translations. To deselect a markup, send a null value. See also getMarkup().

    Parameters

    markup*
    Autodesk.Viewing.Extensions.Markups.Core.Markup, null
    The markup instance to select. Set the value to null to deselect a markup.
    * Required

    getSelection()

    Returns the currently selected markup. A selected markup has a custom UI overlayed that allows you to perform resizing, rotations and translations. See also selectMarkup().

    Returns

    typedescription
    Autodesk.Viewing.Extensions.Markups.Core.Markup, null Returns selected markup object; null if no markup is selected.

    deleteMarkup(markup, dontAddToHistory)

    Deletes a markup from the canvas. Only applies while in Edit mode.

    Parameters

    markup*
    Autodesk.Viewing.Extensions.Markups.Core.Markup
    Markup object.
    dontAddToHistory
    boolean
    Whether delete action can be undone.
    * Required

    loadMarkups(markupString, layerId)

    Loads data (SVG string) for all markups in a specified layer (layerId) to the Viewer’s canvas.

    See also unloadMarkups(), and hideMarkups().

    Parameters

    markupString*
    string
    SVG string with markups. See also generateData().
    layerId*
    string
    Identifier for the layer where the markup should be loaded to. Example “Layer1”.
    * Required

    Returns

    typedescription
    boolean Whether the markup string was able to be loaded successfully

    revertLayer(layerId)

    Revert any changes made to the specific layer.

    See also loadMarkups() and enterEditMode().

    Parameters

    layerId*
    string
    ID of the layer to revert any changes that were made to it.
    * Required

    Returns

    typedescription
    boolean true if the layer was unloaded, false if the layer was not unloaded.

    unloadMarkups(layerId)

    Removes markups from the DOM (Document Object Model). This is helpful for freeing up memory.

    See also loadMarkups(), unloadMarkupsAllLayers(), clear(), hide(), and hideMarkups().

    Parameters

    layerId*
    string
    ID of the layer containing all markups to unload (from the DOM).
    * Required

    Returns

    typedescription
    boolean Whether the operation succeeded or not.

    unloadMarkupsAllLayers()

    Removes all markups loaded so far. Great for freeing up memory.

    See also loadMarkups(), unloadMarkups(), clear(), hide(), and hideMarkups().

    hideMarkups(layerId)

    Hides all markups in a specified layer. Note that hidden markups will not be unloaded. Use the showMarkups() method to make them visible again; no additional parsing is required.

    See also showMarkups(), unloadMarkups(), and loadMarkups().

    Parameters

    layerId*
    string
    ID of the layer containing all markups that should be hidden (in the DOM).
    * Required

    Returns

    typedescription
    boolean Whether the operation succeeded or not.

    showMarkups(layerId)

    Unhides a layer of hidden markups (hideMarkups()).

    Parameters

    layerId*
    string
    ID of the layer containing all markups to unload (from the DOM).
    * Required

    Returns

    typedescription
    boolean Whether the operation succeeded or not.

    Events

    EVENT_EDITMODE_CHANGED

    Fired whenever the drawing tool changes. For example, when the Arrow drawing tool changes into the Rectangle drawing tool.

    EVENT_EDITMODE_ENTER

    Fired when Edit mode has been enabled, which allows the end user to start drawing markups over the Viewer canvas.

    EVENT_EDITMODE_LEAVE

    Fired when Edit mode has been disabled, preventing the end user from drawing markups over the Viewer canvas.

    EVENT_MARKUP_SELECTED

    Fired when a drawn markup has been selected by the end user with a click command.

    Properties

    markup
    Markup
    The selected markup

    EVENT_MARKUP_DRAGGING

    Fired when a drawn markup is being dragged over the Viewer canvas.

    EVENT_HISTORY_CHANGED

    Fired whenever a new undo or redo action is available.

    Properties

    dataThe event data to identify the action and target

    EVENT_EDITMODE_CREATION_BEGIN

    Fired when a markup creation begins. For example, as soon as the user starts dragging with the mouse to draw an arrow on the screen.

    EVENT_EDITMODE_CREATION_END

    Fired when a markup has been created. For example, as soon as the user stops dragging and releases the mouse button to finish drawing an arrow on the screen

    EVENT_MARKUP_DESELECT

    Fired when a markup is no longer selected.

    Properties

    markupId
    number
    The id of the selected markup

    EVENT_EDITFRAME_EDITION_START

    The selected markup is being modified, i.e, resizing, rotating, moving around

    EVENT_EDITFRAME_EDITION_END

    The selected markup is no longer being modified