Sam Curry
Sam Curry

Reputation: 475

How can I load a unique database ID onto a MarkupCore extension markup?

I am using the MarkupsCore extension to build a cloud-based annotation system. I am able to successfully store markups in the database individually, and load them back as one whole SVG string. However, I am confused on being able to delete them. Ordinarily, I would attach a database ID to the markup, and delete it by that. But, I do not know how I would do that in this case. Are there any unique attributes that I could store that are part of the markups to use to identify them to delete them with?

Also, is there a particular reason that the MarkupsCore extension doesn't have an event that is fired when a markup is created? I was able to resolve this problem myself, but I am just curious.

Upvotes: 0

Views: 103

Answers (1)

Petr Broz
Petr Broz

Reputation: 9934

If you want to bypass the standard storage mechanism (using the generateData() and loadMarkups() methods on the MarkupCore extension), you could potentially store the data separately, and re-create the markup procedurally using the following approach:

viewer.loadExtension('Autodesk.Viewing.MarkupsCore').then((extension) => {
    const CoreNS = Autodesk.Viewing.Extensions.Markups.Core;
    extension.clear();
    extension.enterEditMode();
    let rect = new CoreNS.MarkupRectangle(123 /* your custom ID */, extension);
    extension.addMarkup(rect);
    rect.setSize({ x: 10, y: 10 }, 100 /* width */, 100 /* height */);
    extension.leaveEditMode();
    console.log('markup data', extension.generateData());
});

Upvotes: 1

Related Questions