70002325 Howto get figure entities added to the undo history

Article 70002325
Type HowTo
Product WebJS
Version 10
Date Added 3/11/2023 12:00:00 AM
Fixed 10.1003.0.3 (3/11/2023 12:00:00 AM)
Submitted by Brendan Fry


Howto get figure entities added to the undo history


use the following code in order to get the figure entities that are added to the undo history

function getModificationEntities() {
            var undostack = vdcanvas.UndoHistory().UndoStack;
            var handledict = {};//keep a dictionary of entities with their handle name
            var entities = [];//return value of a figure collection
            for (var i = 0; i < undostack.length; i++) {
                var obj = undostack[i].obj;//get the object of undo record
                if (!obj || !obj['_t']) continue;//figure objects contains _t property
                if (obj._t === vdConst.vdTextstyle_code) continue;//exclude TextStyles form the return collection
                handledict['h_' + obj.HandleId.toString()] = obj;//set the dictionary value in order to have unique entities in the return list
            //fill the return collection
            for (prop in handledict) {
                if (prop.substr(0, 2) == 'h_') entities.push(handledict[prop]);
            return entities;
var ents = getModificationEntities();

Send comments on this topic.