2 回答
TA贡献1876条经验 获得超7个赞
可以通过 viewer.getState() 获取 Philippe MarkUp3D 的 Markup 信息,把这个信息记录到数据库里;之后重载模型后执行 viewer.restoreState( viewstate ) 就可以回复了,原因是因为载入 MarkUp3D 扩展后,你的 viewState 会多了一个叫 Markup3D 的属性,在回复时 MarkUp3D 扩展会去读取这个属性将 Markup 回复到画面上,我的测试代码如下:
var viewstate = viewer.getState();
viewer.restoreState( viewstate );
数据结构:
希望对您有帮助
TA贡献1848条经验 获得超6个赞
存:var info = viewer.getState();
var str = JSON.stringify(info);
document.inputForm.elements["markup"].value = str;
没有问题。
为什么恢复的时候 无效果:
function onDocumentLoadSuccess(doc) {
// A document contains references to 3D and 2D viewables.
viewables = Autodesk.Viewing.Document.getSubItemsWithProperties(doc.getRootItem(), {'type':'geometry'}, true);
if (viewables.length === 0){
console.error('Document contains no viewables.');
return;
}
// Choose any of the avialble viewables
var initialViewable = viewables[0];
var svfUrl = doc.getViewablePath(initialViewable);
var modelOptions = {
sharedPropertyDbPath: doc.getPropertyDbPath()
};
var viewerDiv = document.getElementById('MyViewerDiv');
viewer = new Autodesk.Viewing.Private.GuiViewer3D(viewerDiv,{
extensions: ['Autodesk.ADN.Viewing.Extension.BasicES2015','Viewing.Extension.Markup3D']
});
/**
,'Autodesk.Viewing.MarkupsGui' //2D标记
,'Autodesk.ADN.Viewing.Extension.PropertyListPanel' //属性菜单
,'Autodesk.ADN.Viewing.Extension.Material'
,'Viewing.Extension.Markup3D' //3D标记
,'Autodesk.Billboard',
,'Autodesk.MyBillboardGui'
*/
var errorCode = viewer.start();
// Check for initialization errors.
if (errorCode) {
console.error('viewer.start() error - errorCode:' + errorCode);
return;
}
// Choose any of the available viewables.
indexViewable = 0;
lmvDoc = doc;
var markup = ${markup};
alert(markup);
if (markup!=null && markup != ""){
viewer.restoreState(markup);
// Everything is set up, load the model.
loadModel();
}
添加回答
举报