| Article | 70002786 |
| Type | HowTo |
| Product | WebJS |
| Date Added | 11/13/2025 12:00:00 AM |
| Fixed | 11.5.2 (11/13/2025 12:00:00 AM) |
| Submitted by | Lorenzo Stanco |
Summary
How to change a parameter of the dimension after it has been created
Solution
Following code example
//create a new dimension manager that holds the dimension properties
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';
//create a dimension using the above dimension manager properties
var dim = dimstyle.Create(vdcanvas, [-3, -2, 0], [3, -2, 0], [0, 0, 0]); //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.
//copy the created dimension to see differences when change some properties
vdcanvas.CmdCopy([dim], [0, 0, 0], [0, 3, 0]);
//change some properties of the first created dimension
var arrowblk = vdcanvas.FindBlock('VDDIM_DEFAULT');
dim.ArrowBlock = 'h_' +arrowblk.HandleId.toString();
dim.TextVerJust = vdConst.DIMTEXT_VERJUST_CENTER;
dim.TextColor = vdConst.colorFromString('255,0,0');
dim.ExtLineColor = vdConst.colorFromString('255,255,0');
dim.DecimalPrecision = 8;
dim.DimLineColor = vdConst.colorFromString('bylayer');
dim.TextHeight = 0.5;
dim.ArrowSize = 0.5;
dim.TextDist = 0.5;
//change some common figure properties
dim.LineWeight = 100;
var newlayer = vdcanvas.AddLayer("newDimLayer");
newlayer.PenColor = vdConst.colorFromString('0,255,255');
dim.Layer = 'h_' + newlayer.HandleId.toString();
vdcanvas.UpdateFig(dim);//mark the dimension as update in order to recalculate its sub-entities
setTimeout(vdcanvas.redraw);
//additional dimension properties that can be changed
//dim.DefPoint1;
//dim.DefPoint2;
//dim.LinePosition;
//dim.ScaleFactor;
//dim.dimText;
//dim.TextHorRotation;
//dim.LinearScaleFactor;
//dim.HorizontalRotation;
//dim.Rotation;
//dim.ExtLineDist1;
//dim.ExtLineDist2;
//dim.EnableExtLineFixedLength;
//dim.ExtLineFixedLength;
//dim.ExtLineVisible;
//dim.LineIsInvisible;
