Table of Contents

Method select

Namespace
vdWebLibrary
Assembly
JsPropertiesExtractor.dll

select(object[], ScriptSelectDelegate)

Add passed entities to default active selection Check the function finished throw the passed callback delegate

public void select(object[] entities, ScriptSelectDelegate callback)

Parameters

entities object[]

An array of entities to be added to active selection or null/undefined in order prompt the user to select entities on the screen

callback ScriptSelectDelegate

A ScriptSelectDelegate user defined function that will be called when user finish the selection

Examples

 //first will prompt the user to select entities.
 //After finish the selection (usually by right-click) then the _cmdselectCallback function will be called.
 //inside the _cmdselectCallback we decide what to do with the selection.In this case we hightlight the selected entities.
   function MySelect() {

       vdcanvas.scriptCommand.select(null, _myselectCallback);
   }
   function _myselectCallback(_vdcanvas) {
       //enum all selected entities
       var selectedEntities = _vdcanvas.scriptCommand.ActiveSelection();
       if (!selectedEntities || selectedEntities.length == 0) return;
       for (var k = 0; k < selectedEntities.length; k++) {
           var fig = selectedEntities[k];
           fig.HighLight = true;
           _vdcanvas.UpdateFig(fig);
       }
       _vdcanvas.redraw();
   }

//See also following examples:

//1.Prompt user to select entities and then prompt to move them
 vdrawObj.scriptCommand.select(null,function (_vdcanvas) { _vdcanvas.scriptCommand.move(); } );
//2.Prompt user to select entities and then prompt to copy them
 vdrawObj.scriptCommand.select(null,function (_vdcanvas) { _vdcanvas.scriptCommand.copy(); } );
//3.Move all entities of active layout from 0,0,0 to 10,10,0 without user prompt
           var entities = [];
           for (var i = 0; i < layout.Entities.Items.length; i++) {
               var h = layout.Entities.Items[i];
               fig = vdrawObj.GetEntityItem(h);
               entities.push(fig);
           }
           vdrawObj.scriptCommand.select(entities,function (_vdcanvas) { _vdcanvas.scriptCommand.move(null,[0,0,0],[10,10,0]); } );
           // or more simple....
           vdrawObj.scriptCommand.move(entities,[0,0,0],[10,10,0]);
//4.Move all entities of active layout without prompt user to select, but prompt for the from and to point
           var entities = [];
           for (var i = 0; i < layout.Entities.Items.length; i++) {
               var h = layout.Entities.Items[i];
               fig = vdrawObj.GetEntityItem(h);
               entities.push(fig);
           }
           vdrawObj.scriptCommand.select(entities,function (_vdcanvas) { _vdcanvas.scriptCommand.move(); } );

Remarks

This method does not write to Unode History but it writes to Script