70001066 New property that exclude entities from save

Article 70001066
Type Wish
Product WebJS
Version 7010
Date Added 4/24/2017 12:00:00 AM
Fixed 7.7011.0.4 (4/25/2017 12:00:00 AM)
Submitted by Brendan Fry

Summary

New property that exclude entities from save

Solution

A new property excludeFromSave of drawing figures, was added in version 7011.0.4
By default this property is undefined
User can set this value any of layout entities only.
Example 1:
Mark all entities in Model that belong to layer "nosave" with excludeFromSave

            var vddoc = vdcanvas.GetDocument();
            var layer0 = vdcanvas.FindLayer('0');//return the default layer
            for (var i = 0; i < vddoc.Model.Entities.Items.length; i++) {//enum entities in model layout
                var entity = vdcanvas.GetEntityItem(vddoc.Model.Entities.Items[i]);//get the entity from handle
                var layer = vdcanvas.GetEntityItem(entity.Layer);//get the entity layer object
                if (!layer) layer = layer0;//use the default document layer if not exist
                if (layer.Name.toLowerCase() == "nosave") entity.excludeFromSave = true; //compare the entity layer name and if it is equal to 'nosave' mark the entity with excludeFromSave in order not to be saved
            }

           vdcanvas.SaveDocument();//save the document
Example 2:
Let the user to select which entities prefers to be saved.
            var vddoc = vdcanvas.GetDocument();
            for (var i = 0; i < vddoc.Model.Entities.Items.length; i++) {//enum entities in model layout
                var entity = vdcanvas.GetEntityItem(vddoc.Model.Entities.Items[i]); //get the entity from handle
                entity.excludeFromSave = true; //  set to all the entities of the drawing ExcludeFromSave = true          
            }
            vdcanvas.scriptCommand.select(null, _cbacksave); // call the user select command

           function _cbacksave(vdcanvas) {
                   var selectedEntities = vdcanvas.scriptCommand.ActiveSelection(); // get all the entities of the selection
                   for (var i = 0; i < selectedEntities.length; i++) {
                          selectedEntities[i].excludeFromSave = false; // set to all the entities of the selection ExcludeFromSave = false so the will be saved
                   }
                   vdcanvas.SaveDocument(); // call the save command
            }

Send comments on this topic.