70001559 How to clear erased items from a layout or a block

Article 70001559
Type HowTo
Product WebJS
Version 8002
Date Added 6/14/2019
Fixed 7 (6/14/2019)
Submitted by Kostas Androulakis

Summary

How to clear erased items of layout or block.

Solution

Bellow we create two different examples for how to clear erased items from the layout or a block.

Example 1: Clear erased items of active Layout

           var tempCol = [];
           var activelayout = vdcanvas.GetActiveLayout();
           for (var k = 0; k < activelayout.Entities.Items.length; k++) {
               var fig = vdcanvas.GetEntityItem(activelayout.Entities.Items[k]);
               if (!fig.Deleted) tempCol.push(activelayout.Entities.Items[k]);//If not an item is Deleted we push it in our tempCol
           }          
           activelayout.Entities.Items = tempCol;//update the active layout entities with the tempCol
Example 2: Clear erased items of a block
           var tempCol = []; 
           var blk = vdcanvas.AddBlock("myblock");//let's say that the block we want to update is the 'blk'
           for (var k = 0; k < blk.Entities.Items.length; k++) {
               var fig = vdcanvas.GetEntityItem(blk.Entities.Items[k]);
               if (!fig.Deleted) tempCol.push(blk.Entities.Items[k]);//If not an item is Deleted we push it in our tempCol
           }        
           blk.Entities.Items = tempCol;//update the block entities with the tempCol

Send comments on this topic.