70001557 Enable or disable osnaps of a specific layer

Article 70001557
Type Wish
Product WebJS
Version 8002
Date Added 6/13/2019
Fixed 8.8003.0.1 (6/19/2019)
Submitted by Brendan Fry


I would like to enable or disable osnaps of a specific lock layer but not allow selection or modification.


In version 8003.0.1 a new boolean property ForceOsnaps of vdlayer and layerRef of a vdfigure was added.
It forces the osnaps of entities reference a Layer to be always visible and not depends if the ignoreLockLayers is true and the layer is locked.
Note that it works for all osnaps except the nearest.

Example where we search for a layer named 'Layer1' which is locked and we enable the osnaps to the entity that belongs to this layer.

            var vddoc = vdcanvas.GetDocument();
            var layers = vdcanvas.GetDocument().Layers;
            for (var i = 0; i < vddoc.Layers.Items.length; i++) {
                var layerref = vdcanvas.GetDictItem(vddoc.Layers, vddoc.Layers.Items[i]);
                if (layerref.Name == "Layer1") { //search by layer name or by layer handle like: layerref.HandleId                
                    layerref.ForceOsnaps = true;                   

Send comments on this topic.