70001570 Add Fence selection to the vdraw web library

Article 70001570
Type Wish
Product WebJS
Version 8002
Date Added 6/28/2019
Fixed 8.8003.0.1 (7/3/2019)
Submitted by Russ Airey

Summary

I would like to add Fence selection to the vdraw web library.

Solution

In version 8003.0.1 GetEntitiesFence(pts,IsWorld) has been exported which returns a collection with all entities which have been selected.

Prameters:
pts :An array of X,Y points
IgnoreLockLayers :Set it to true for selection in WorldCS or to false for pixel selection.

Example: In the example bellow we create tow vertical lines to X axis ( line1 = [2, 2, 0], [2, 8, 0] line2 = [8, 2, 0], [8, 8, 0]) and then we create a third horizontal line
from which we will use the two points in order to select the tow vertical lines.

        var line1 = vdcanvas.AddLine([2, 2, 0], [2, 8, 0], true);//first vertical line
        var line2 = vdcanvas.AddLine([8, 2, 0], [8, 8, 0], true);//second vertical line
        var p1 = vdcanvas.WorldToView(vdgeo.newpoint(0, 0, 0));
        var p2 = vdcanvas.WorldToView(vdgeo.newpoint(10, 10, 0));
        vdcanvas.zoomwindow(p1, p2);//zoom the scene in order to see better the lines
        vdcanvas.redraw();// redraw the scene so we will see all the entities in the right zoom  
        var lineFence = vdcanvas.AddLine([1, 5, 0], [9, 5, 0], true);//create the third line which is vertical to the two others
        var figs = vdcanvas.GetEntitiesFence([[1, 5, 0], [9, 5, 0]], true);//it returns us all the three lines
        for (var i = 0; i < figs.length; i++) {
             figs[i].HighLight = true;//highlight the selected entities to understand better the result
        }
        setTimeout(vdcanvas.redraw);//post a redraw to see the highlight entities.

Send comments on this topic.