70001521 Get the entities and the bounding box of a group

Article 70001521
Type Wish
Product WebJS
Version 8001
Date Added 4/17/2019 12:00:00 AM
Fixed 8.8002.0.3 (4/18/2019 12:00:00 AM)
Submitted by Brendan Fry

Summary

Additional properties of vdcanvas.groupsManager in order to get the entities and the bounding box of a group

Solution

In version 8002.0.4 GetEntities method has been exported for GroupsManagerand by using it you are able to get all the entities of an existing group.
Also in GetEntityBBox method has been added the ability to set an array of entities and not also a single entity.
Example for how to use the new fuctionality.We create a new group named "group1" and we add to it three lines.Then we get all the entities of a group,
their whole bounding box and we flip(mirror) them around the X axis with the center point of the bounding box of all entities.

        var line1 = vdcanvas.AddLine([0, 0, 0], [1, 1, 0],true);
        vdcanvas.GroupsManager.AddItem("group1", line1);
        
        var line2 = vdcanvas.AddLine([0, 0, 0], [1, 0, 0], true);
        vdcanvas.GroupsManager.AddItem("group1", line2);
        
        var line3 = vdcanvas.AddLine([0, 0, 0], [0, 1, 0], true);
        vdcanvas.GroupsManager.AddItem("group1", line3);

        var ents = vdcanvas.GroupsManager.GetEntities("group1");

        var box = vdcanvas.GetEntityBBox(ents);//the bounding box of all entities of the group

        if (box) {//if the box exist
            var pt1 = vdgeo.newpoint(box[0], box[1], box[2]); // The lower left point of the bounding box 
            var pt2 = vdgeo.newpoint(box[3], box[4], box[5]); // The upper right point of the bounding box 
            var center = vdgeo.MidPoint(pt1, pt2); // The middle point between lower left and upper right point of the bounding box 
        }
        vdcanvas.CmdScale(ents, center,[-1.0,1.0,1.0,0])//flip the entities around the X axis

Send comments on this topic.