Request

Response

    Extensions

    Autodesk.Viewing.Extensions.Markups.Core.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. show().
    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

    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

    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.Markups.Core.EVENT_EDITMODE_CHANGED.

    Parameters

    editMode*
    Object
    Object instance for the drawing tool
    * Required

    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 Edit mode.

    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().

    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

    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 interaction with markups; default false.
    * Required

    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

    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 Edit mode.

    Returns

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

    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.

    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.

    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.

    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.

    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.

    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.

    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.

    leaveEditMode()

    Exits Edit mode.

    See also enterEditMode().

    Returns

    TypeDescription
    boolean Returns true if Edit mode has been deactivated

    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

    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().

    redo()

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

    renderToCanvas(context)

    Renders the markups onto a 2D canvas context to generate an image.

    Parameters

    context*
    CanvasRenderingContext2D
    Markups are drawn using the context provided
    * Required

    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.

    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

    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.

    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.

    toggle()

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

    toggleEditMode()

    Toggle in and out of Edit mode. In Edit mode the user is able to draw markups on the canvas.

    See also enterEditMode() and leaveEditMode()

    undo()

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

    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().


    Events

    EVENT_EDITMODE_CHANGED

    Fired whenever the drawing tool changes. For example, when the Arrow drawing tool changes into the Rectangle drawing tool. See MarkupsCore.changeEditMode() for a list of all supported drawing tools (EditModes).

    EVENT_EDITMODE_ENTER

    Fired when Edit mode has been enabled, which allows the end user to start drawing markups over the Viewer canvas. See also MarkupsCore.enterEditMode().

    EVENT_EDITMODE_LEAVE

    Fired when Edit mode has been disabled, preventing the end user from drawing markups over the Viewer canvas. See also MarkupsCore.leaveEditMode().

    EVENT_MARKUP_DRAGGING

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

    EVENT_MARKUP_SELECTED

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