70001534 Export Dimension block method in Webcontrol that returns the object

Article 70001534
Type Wish
Product WebJS
Version 8001
Date Added 5/20/2019
Fixed 8.8002.0.4 (5/22/2019)
Submitted by tongguobiao

Summary

Export Dimension block method in Webcontrol that returns the object and can be added in the entities of the layout or in the entities of a block.

Solution

Added in version 8002.0.4.

Properties of dimension block:

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 as string 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 like 'Red,Green,Blue,Alpha' '255,0,0,255'etc. or '1' for index color of document palette or 'Byblock' or 'Bylayer'.Default value is 'byblock'
EXTCOLOR: The color of the dimension extension line as string like 'Red,Green,Blue,Alpha' '255,0,0,255'etc. or '1' for index color of document palette or 'Byblock' or 'Bylayer'.Default value is 'byblock'
TEXTCOLOR: The color of the dimension text as string like 'Red,Green,Blue,Alpha' '255,0,0,255'etc. or '1' for index color of document palette or 'Byblock' or 'Bylayer'.Default value is 'byblock'
DIMTEXT: The dimension text to be displayed as string.It can be an empty string '' in order to get the dimension length or any string value to be displayed.
TEXTHORROT: The text horizontal rotation.It can be 'ALIGN' or 'HORIZONTAL'
TEXTVERJUST: The text vertical rotation.It can be 'ABOVE' or 'CENTER'
Create: (vdrawObj vdcanvas, object DefPoint1, object DefPoint2, object LinePosition, string PostString, object entities) Returns the vdraw object that corresponds to the given canvas.

Example: We create a new line from [0,0,0] to [3,3,0] and we add a new align dimension using the properties bellow.


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

 function actionentityadded(vdraw, entity) {

            var dimstyle = new vddimmanager();//create the object
            dimstyle.TYPE = 'ALIGN';
            dimstyle.BLK = 'ARROW';
            dimstyle.TEXTH = '0.4';
            dimstyle.LUNITS = 'DEC';
            dimstyle.PREC = '5';
            dimstyle.SZEROS = '0';
            dimstyle.LINECOLOR = '255,0,0,255';
            dimstyle.EXTCOLOR = '0,255,0,255';
            dimstyle.TEXTCOLOR = '0,0,255,255';
            dimstyle.DIMTEXT = '';
            dimstyle.TEXTHORROT = 'ALIGN';
            dimstyle.TEXTVERJUST = 'ABOVE';

            var firstPoint = entity.StartPoint;//the first point of the line
            var endPoint = entity.EndPoint;//the end point of the line
            var rotation = vdgeo.GetAngle(firstPoint, endPoint);//the rotation between the two points

            var polar = vdgeo.pointPolar(firstPoint, rotation + vdgeo.HALF_PI, 0.6);//find the point of the dimension 

            var dim = dimstyle.Create(vdcanvas, firstPoint, endPoint, polar, '');//the dimension will be added in the entities of the layout
            vdcanvas.DrawEntity(dim);//draw the new object on the canvas
            vdcanvas.Refresh();..refresh the canvas element in order to see the result.
 }

 

Send comments on this topic.