Table of Contents

Method SetEntityPosition

Namespace
vdWebLibrary
Assembly
JsPropertiesExtractor.dll

SetEntityPosition(object, int, object)

change the entity position inside the passed collection

public int SetEntityPosition(object entity, int pos, object collection)

Parameters

entity object

An object reference

pos int

An integer(zero based) to new position, if pos <0 move the entity to the begin of the collection.if >= collection.length move it at the end The entity that was previous in pos move to pos+1 if passed entity was after pos -or to pos-1 if passed entity was before pos .

collection object

A collection where the entity belongs. If not defined the ActiveLayout entities is used. If entity does not belongs to the collection the function returns -1.

Returns

int

New position of the passed entity or -1 for no success

Examples

vdcanvas.SetActiveHatchProperties(vdcanvas.createNewHatchProperties('solid', vdConst.colorFromString("byblock"), vdConst.colorFromString("255,255,255")));//solid white circle
var c0 = vdcanvas.AddCircle([0, 0, 0], 5);
vdcanvas.SetActiveHatchProperties(vdcanvas.createNewHatchProperties('solid', vdConst.colorFromString("byblock"), vdConst.colorFromString("255,0,0")));//solid red circle
var c1 = vdcanvas.AddCircle([1, 1, 0], 5);
vdcanvas.SetActiveHatchProperties(vdcanvas.createNewHatchProperties('solid', vdConst.colorFromString("byblock"), vdConst.colorFromString("0,255,0")));//solid green circle
var c2 = vdcanvas.AddCircle([2, 0, 0], 5);
vdcanvas.SetActiveHatchProperties(vdcanvas.createNewHatchProperties('solid', vdConst.colorFromString("byblock"), vdConst.colorFromString("0,0,255")));//solid blue circle
var c3 = vdcanvas.AddCircle([3, 1, 0], 5);
//move the blue circle to the posistion of red circle (red circle will be placed just after blue)
vdcanvas.SetEntityPosition(c3, vdcanvas.GetEntityPosition(c1));
//-or-
//move blue circle to start of the active layout entities collection
vdcanvas.SetEntityPosition(c3, 0);
//-or-
//move white circle at the end of active layout entities collection
vdcanvas.SetEntityPosition(c0, 100000/*enough bigger that entities length in active layout collection*/);
See Also