response data for svg markups
markups in model
I want to save all svg Markups on model and show them.
I try to save Markups with this code
```markupsPersist = markup.generateData();
viewerStatePersist = markup.viewer.getState();
markup.viewer.restoreState(viewerStatePersist);```
and try to get it with this
markup.viewer.restoreState(viewerStatePersist);
markup.show();
markup.loadMarkups(markupsPersist, "markups-svg");
but Markups dont appear.
You should also call showMarkups after loading them using loadMarkups.
Related
I am hosting Forge Viewer as a component in my own GUI. I am wondering if I can map Forge Viewer buttons to external buttons in my own GUI.
An as example, instead of clicking on the model browser button in Forge Viewer, I want to be able to click on a button in my own GUI in order to see the tree view of the loaded model in forge viewer.
Such feature is already implemented in viewer.autodesk.com for model browser button, and I am wondering how I can do so.
Sure thing. These default controls are usually nested inside extensions that house the ui for that functionality. However you can get any extension by name after initaliazing the viewer using getExtension You now have a reference to the extension which you can control
Please try this is browser console:
let ext = null
let gotExtension = function(extension){
ext = extension
}
let openEvent = function(extension){
extension.activate();
}
let closeEvent = function(extension){
extension.deactivate();
}
NOP_VIEWER.getExtension('Autodesk.ModelStructure', gotExtension);
openEvent(ext);
I have a markup extension in Autodesk Forge Viewer for 3D models. I have problems removing only one markup. I want to know if it is possible to show annotations in edit mode or delete markups in show mode. When I try to show markups in editing mode, I see a warning that "markups cant be showed in editing mode."
Does anyone know how to solve this problem?
Edit
And to remove a specific markup from a layer after they are loaded try:
markExt.svgLayersMap['layerId'].markups[index].destroy()
Leave the editmode before showing markups - (in response to user input) you can programmatically re-enter editmode once the markups are shown:
ext.leaveEditMode()
ext.loadMarkups(asb,'233') //or ext.showMarkups(layerID)
ext.enterEditMode()
And to remove markups try:
ext.markups[0].destroy()
show annotations in edit mode
Not exactly sure what you are trying to achieve here? But you can create text markup programmatically - say for exp:
const styleObject = Autodesk.Viewing.Extensions.Markups.Core.Utils.createStyle(['font-size'], window.ext);
styleObject['font-size'] = 100;
(new Autodesk.Viewing.Extensions.Markups.Core.CreateText(window.ext, 2333, {x:20,y:20}, {x:100,y:100},'233', styleObject)).execute()
or delete markups in show mode.
And in show mode if the markups are loaded you will need to hide on their layer level and wouldn't be able to hide a specific markup - you may fine tune this by separating them to different layers
While loading markups, I am not able to get markups array from markup extension as referneced in below code, actually I need client position coordinates of the loaded markup. In below code am getting markups array empty. But while drawing a new markup, we always have markup array filled.
Please advise
markup.viewer.restoreState(viewState);
markup.loadMarkups(svgTxt, "layerName")
var pos = markup.markups[0].getClientPosition()
Since you're not editing the layer you specified, the markupExt.markups will not contain anything. Please use this instead:
const activeLayerMarkup = markupExt.svgLayersMap[markupExt.activeLayer]
activeLayerMarkup.markups[0].getClientPosition()
Or try to edit the layer
markupExt.loadMarkups(svgTxt, 'layerName')
markupExt.enterEditMode('layerName')
markup.markups[0].getClientPosition()
Can we edit saved markups which we draw on a viewer?
Does it only support view using restoreState and loadMarkups functions?
Or is there anyway I can update the created and saved markups as my functionality requires reviewer User should be able to update this markups.
var markupsPersist = markup.generateData()
// current view state (zoom, direction, sections)
var viewerStatePersist = markup.viewer.getState()
// finish edit of markup
markup.leaveEditMode()
// hide markups (and restore Viewer tools)
markup.hide()
// restore the view to the state where the markups were created
markup.viewer.restoreState(viewerStatePersist)
// show markups
markup.show();
// show the markups on a layer
markup.loadMarkups(markupsPersist, "layerName")
Of course you can access the markups via markupExt.markups and for example you can edit the text markup with below:
const textMarkup = markupExtension.markups[0]; //access the existing markups via markupExtensionObject.markups
textMarkup.setText('new text');
markupExtension.leaveEditMode();
markupExtension.enterEditMode() //be sure to re-enter edit mode for the changes to take effect
I ran into this this scenario too and you can edit a saved markup. You may need to store your markup state to your own database to be accessed and restored later by the Reviewer. Here is a sample that shows this functionality.
https://forge-rcdb.autodesk.io/configurator?id=598d7ec14cabf2c1f4dec948
Here is blog post discussing this as well.
https://forge.autodesk.com/blog/high-performance-3d-markups-pointcloud-forge-viewer
I am using Autodesk.Viewing.MarkupCore extension to create markups then I store viewer'state and the svg string in my database. When I try to show the markups on a layer, the restoreState function doesn't seem to work . It just displays the markups with the current state of the viewer.
Here is the three lines of code:
markup.show();
markup.viewer.restoreState(viewerStatePersist);
markup.loadMarkups(markupsPersist, "layerName");
When I comment the first line (markup.show() ) I have the desired state without the markups.