70001070 Add dimension block in Web Control

Article 70001070
Type Wish
Product WebJS
Version 7010
Date Added 4/27/2017 12:00:00 AM
Fixed 7.7011.0.5 (5/4/2017 12:00:00 AM)
Submitted by Brendan Fry

Summary

I would like to have the ability to add dimension in Web Control

Solution

Add dimension block in Web Control was added in version 70011.0.5
Tow new methods have been added in version 7011.0.5 The vdcanvas.scriptCommand.dimvar() method which sets the properties of the dimension,
and the vdcanvas.scriptCommand.dim() which add a new dimension block in predefined points or in active action where the user wants.
Example1:We prompt the user to add a new dimension with bellow properties

TYPE: The value can be 'ALIGN' for aligned dimension or 'HOR' for horizontal or 'VER' for vertical.Default value is 'ALIGN'
BLK: The block name that is drawn at the ends of the dimension line. The value can be 'ARROW' or 'TICK' or '' empty for no block or an existing block name in the document Blocks collection.Default value is 'TICK'.
TEXTH: The text height in drawing units as string.Default value is '0.2'
LUNITS: The unis that used to format the dimension text.The value can be 'DEC' for decimal unirs,'ENG' for Engineering 'ARC' for Architectural 'FRAC' for Fractional 'SC' for Scientific.Default value is 'DEC'
PREC: The number of decimals as integer string.The value must be between 0 to 12.Default value is '4'
SZEROS: The suppression of zero of the default dim length text.The value can be '0' for no suppression or '1' for suppression leading and trailing zeros.Default value is '0'
LINECOLOR: The color of the dimension line as string.Default value is 'byblock'
EXTCOLOR: The color of the dimension extension line as string.Default value is 'byblock'
TEXTCOLOR: The color of the dimension text as string.Default value is 'byblock'

vdcanvas.scriptCommand.color('255,0,0');

vdcanvas.scriptCommand.dimvar('TYPE', 'align');
vdcanvas.scriptCommand.dimvar('BLK', 'vddim_default');
vdcanvas.scriptCommand.dimvar('TEXTH', '0.3');
vdcanvas.scriptCommand.dimvar('LUNITS', 'dec');
vdcanvas.scriptCommand.dimvar('PREC', '3');
vdcanvas.scriptCommand.dimvar('SZEROS', '0');
vdcanvas.scriptCommand.dimvar('LINECOLOR', 'byblock');
vdcanvas.scriptCommand.dimvar('EXTCOLOR', '0,255,0');
vdcanvas.scriptCommand.dimvar('TEXTCOLOR', '100,200,255');
vdcanvas.scriptCommand.dim(); vdcanvas.zoomExtents(); vdcanvas.redraw();

Example2:We add a new horizondal dimension with following properties

vdcanvas.scriptCommand.color('255,0,0');

vdcanvas.scriptCommand.dimvar('TYPE', 'hor');
vdcanvas.scriptCommand.dimvar('BLK', 'tick');
vdcanvas.scriptCommand.dimvar('LINECOLOR', '0,0,255');
vdcanvas.scriptCommand.dimvar('EXTCOLOR', '0,0,255');
vdcanvas.scriptCommand.dim([[0, 0, 0], [4, 4, 0], [0, -1, 0]]);
vdcanvas.zoomExtents();
vdcanvas.redraw();

Example3:We add a new vertical dimension with following properties

vdcanvas.scriptCommand.color('255,0,0');

vdcanvas.scriptCommand.dimvar('TYPE', 'ver');
vdcanvas.scriptCommand.dimvar('LINECOLOR', '255,0,255');
vdcanvas.scriptCommand.dimvar('EXTCOLOR', '255,0,255');
vdcanvas.scriptCommand.dim([[0, 0, 0], [4, 4, 0], [5, 4, 0]]);
vdcanvas.zoomExtents();
vdcanvas.redraw();
vdcanvas.zoomExtents();
vdcanvas.redraw(); Example4:We create a new line from [-3,-3,0] to [3,3,0] and we add a new vertical,horizontal and align dimension on it

vdcanvas.scriptCommand.line([[-3, -3, 0], [3, 3, 0]], actionentityadded);

function actionentityadded(vdrawobj, entity) {

vdcanvas.scriptCommand.color('255,0,0');
vdcanvas.scriptCommand.dimvar('BLK', 'vddim_default');
vdcanvas.scriptCommand.dimvar('TEXTH', '0.3');
vdcanvas.scriptCommand.dimvar('LUNITS', 'dec');
vdcanvas.scriptCommand.dimvar('PREC', '2');
vdcanvas.scriptCommand.dimvar('SZEROS', '0');
vdcanvas.scriptCommand.dimvar('LINECOLOR', 'byblock');
vdcanvas.scriptCommand.dimvar('EXTCOLOR', '0,255,0');
vdcanvas.scriptCommand.dimvar('TEXTCOLOR', '100,200,255');
vdcanvas.scriptCommand.dimvar('TYPE', 'align');

var firstPoint = entity.StartPoint;
var endPoint = entity.EndPoint;
var rotation = vdgeo.GetAngle(firstPoint, endPoint);

var polar = vdgeo.pointPolar(firstPoint, rotation + vdgeo.HALF_PI, 0.6);

vdcanvas.scriptCommand.dimvar('TYPE', 'align');
vdcanvas.scriptCommand.dim([firstPoint, endPoint, polar]);

vdcanvas.scriptCommand.dimvar('TYPE', 'ver');
vdcanvas.scriptCommand.dim([firstPoint, endPoint, endPoint]);

vdcanvas.scriptCommand.dimvar('TYPE', 'hor');
vdcanvas.scriptCommand.dim([firstPoint, endPoint, firstPoint]);

setTimeout(vdcanvas.redraw);
}

Send comments on this topic.