70000070 New actions move, scale, rotate added in web library

Article 70000070
Type Wish
Product WebJS
Version 7002
Date Added 9/17/2014
Fixed (3/11/2015)
Submitted by Rui G de Oliveira

Summary

New actions move, scale, rotate added in web library.

Solution

In version 7003.1 three new commands were added in vectordraw web library. Through these commands the user can move, scale or rotate entities within the model.

To do so the following commands can be used.

CmdMove(entities, from, to)

The function takes the following parameters
  • entities: An array of vdraw entities or null so the user can pick the objects on screen.
  • from: The base point in World coordinates or null so the user can pick this point to the screen. This point will be the origin of the move command.
  • to: Another point representing where the objects will be placed in World coordinates or null so the user picks this point on screen.

Example

 
    var vdcanvas = vdmanager.vdrawObject(canvasId);          
    vdcanvas.CmdMove(null, null, null);

CmdScale(entities, referencePoint, scale)

The function takes the following parameters
  • entities: An array of vdraw entities or null so the user can pick the objects on screen.
  • referencePoint: A reference point object in World coordinates or null so the user can pick this point on screen. This point will be used as scale base point.
  • scale: The scale to be used for the command or null in order for the user to select it on screen.

Example

 
    var vdcanvas = vdmanager.vdrawObject(canvasId);          
    var handles = vdcanvas.GetActiveLayout().Entities;
    var entities = [];
    for (var k = 0; k < handles.Items.length; k++) {
        var fig = vdcanvas.GetEntityItem(handles.Items[k]);
        entities.push(fig);
    }
    vdcanvas.CmdScale(entities, vdgeo.newpoint(0,0,0), null);

CmdRotate(entities, rotationCenter, angle)

The function takes the following parameters
  • entities: An array of vdraw entities or null so the user can pick the objects on screen.
  • rotationCenter: A reference point object in World coordinates or null so the user can pick this point on screen. This point will be used as the rotation base point.
  • angle: The angle (in radians) to be used for the command or null in order for the user to select it on screen.

Example

 
    var vdcanvas = vdmanager.vdrawObject(canvasId);          
    var handles = vdcanvas.GetActiveLayout().Entities;
    var entities = [];
    for (var k = 0; k < handles.Items.length; k++) {
        var fig = vdcanvas.GetEntityItem(handles.Items[k]);
        entities.push(fig);
    }
    var rads = vdgeo.DegreesToRadians(90);
    vdcanvas.CmdRotate(entities, null, rads);

Send comments on this topic.