%%PageItemTitle%%

VectorDraw Web Library

JsPropertiesExtractor Send comments on this topic.
dim Method
See Also  Example
vdWebLibrary Namespace > ScriptCommands Class : dim Method
parameters
Null for user input or an array of parameters in the following order, used for no user action. 1.Dimension line point 1 in world Coordinate System 2.Dimension line point 2 in world Coordinate System 3.Dimension line location in world Coordinate System 4.optional Dimension line text.If not present then the length of the dimesion is used
callback
A user function of ScriptEntityDelegate type, that will be called when the command finish successfully.It can be ignored.
Add a dimension block to the document according the the active dimension style properties dimvar.

Syntax

JScript 
public function dim( 
   parameters : Object[],
   callback : ScriptEntityDelegate
);

Parameters

parameters
Null for user input or an array of parameters in the following order, used for no user action. 1.Dimension line point 1 in world Coordinate System 2.Dimension line point 2 in world Coordinate System 3.Dimension line location in world Coordinate System 4.optional Dimension line text.If not present then the length of the dimesion is used
callback
A user function of ScriptEntityDelegate type, that will be called when the command finish successfully.It can be ignored.

Example

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
C#Copy Code
              
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); 
}

Remarks

if passed parameters not exist or it is null then start a new user action and prompts the user to draw a dimension line. If parameters are not null then a new dimension block is added synchronously depend on the passed parameters. The command add the action to undo history and also to script lines getCommands If parameters are not null and after this command is finished the object is not drawn on screen In order to display it call DrawEntity and Refresh inside the user define callback .See example.

See Also