简体   繁体   中英

MarkupsCore is not run

i have follow https://developer.autodesk.com/en/docs/viewer/v2/reference/javascript/markupscore/ api to get markup,but it can not run,This is my code for loading in the viewer:

<script src="https://developer.api.autodesk.com/viewingservice/v1/viewers/three.min.js"></script>
<script src="https://developer.api.autodesk.com/viewingservice/v1/viewers/viewer3D.min.js"></script>
var viewerDiv = document.getElementById('MyViewerDiv');
viewer = new Autodesk.Viewing.Private.GuiViewer3D(viewerDiv);
viewer.start(svfUrl, modelOptions, onLoadModelSuccess, onLoadModelError);
var config = {markupDisableHotkeys:false};
markup=new Autodesk.Viewing.Extensions.Markups.Core.MarkupsCore(viewer,config);
console.log(markup);
var markupstatus=markup.enterEditMode();
console.log("markupstatus"+markupstatus);

but it can not run and throw error in: markup.enterEditMode();

TypeError: Argument 1 of Node.appendChild is not an object.  
...ESIZE_EVENT,this.onViewerResizeBinded),a.container.appendChild(this.svg),this.in...
viewer3D.min.js (42 row,19037 line)

Any help is highly appreciated!

This failure message stands for that Autodesk.Viewing.Extensions.Markups.Core.MarkupsCore was not be initialized properly by rule of thumb, so you can just add a single line markup.load() before console.log(markup); , and it will be gone.

Here is my testing codes, hope you enjoy it~

var viewer;
Autodesk.Viewing.Initializer(options, function onInitialized() {
  var viewerDiv = document.getElementById( 'viewer' );

  viewer = new Autodesk.Viewing.Private.GuiViewer3D( viewerDiv );
  viewer.start( svfUrl, modelOptions, onLoadModelSuccess, onLoadModelError );
});

function onLoadModelSuccess() {
  var config = { markupDisableHotkeys: false };
  markup = new Autodesk.Viewing.Extensions.Markups.Core.MarkupsCore( viewer,config );

  // Missing line here
  markup.load();

  var markupstatus = markup.enterEditMode();
  console.log( 'markupstatus: ' + markupstatus );
}

function onLoadModelError() {
  console.error( 'Failed to load model' );
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM