Method scale
- Namespace
- vdWebLibrary
- Assembly
- JsPropertiesExtractor.dll
scale(object, double, ScriptSelectDelegate)
Scales the passed entities by a point reference in worldcs. It also write to UndoHistory() and script buffer Check the function finished throw the passed callback delegate
public void scale(object originPoint, double scaleFactor, ScriptSelectDelegate callback)
Parameters
originPointobjectA point in world CS or undefined for user prompt
scaleFactordoubleA scale factor as double for scaling all X,Y,Z the same or an array of four(4) doubles where the first used for X scale, the second for Y scale,the third for Z scale and the fourth one must be always 0 when user wants to achieve separately scale or undefined for user prompt
callbackScriptSelectDelegateA ScriptSelectDelegate user defined function that will be called when the command finish
Examples
1.Scaling all the entities of the layout ten times bigger.
//1. prompt the user for selection
vdrawObj.scriptCommand.select(null,function (_vdcanvas) { _vdcanvas.scriptCommand.scale(); } );
//2. No user prompt do this action for all active layout entities
var entities = [];
var layout = vdcanvas.GetActiveLayout();
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.scale([0,0,0],10); } );//scale from 0,0 10 times biger
2.Get all the entities of the layout and we flip(mirror) them around the X axis.
var ents = [];
var layout = vdcanvas.GetActiveLayout();
for (var i = 0; i < layout.Entities.Items.length; i++) {
var h = layout.Entities.Items[i];//the handle of each entity
var entity = vdcanvas.GetEntityItem(h);
ents.push(entity);
}
var box = vdcanvas.GetEntityBBox(ents);//the bounding box of all entities
if (box) {//if the entity 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.scriptCommand.select(ents, function (_vdcanvas) { _vdcanvas.scriptCommand.scale(center,[- 1.0,1.0,1.0,0.0]); });