%%PageItemTitle%%

VectorDraw Web Library

JsPropertiesExtractor Send comments on this topic.
polyline Method
See Also  Example
vdWebLibrary Namespace > ScriptCommands Class : polyline Method
parameters
An array that contains the VertexList of the polyline.For example it can be [[1,1,0],[2,2,0],[2,0,0]]
closed
Set it to true in order to draw a closed polyline
splineflag
Defines the SplineFlag for the polyline.Valid values are SplineFlagSTANDARD or SplineFlagFITTING or SplineFlagCONTROLPOINTS or SplineFlagQUADRATIC
callback
A user function of ScriptEntityDelegate type, that will be called when the command finish successfully.It can be ignored.
Add a polyline to the document.

Syntax

JScript 
public function polyline( 
   parameters : Object[],
   closed : boolean,
   splineflag : int,
   callback : ScriptEntityDelegate
);

Parameters

parameters
An array that contains the VertexList of the polyline.For example it can be [[1,1,0],[2,2,0],[2,0,0]]
closed
Set it to true in order to draw a closed polyline
splineflag
Defines the SplineFlag for the polyline.Valid values are SplineFlagSTANDARD or SplineFlagFITTING or SplineFlagCONTROLPOINTS or SplineFlagQUADRATIC
callback
A user function of ScriptEntityDelegate type, that will be called when the command finish successfully.It can be ignored.

Example

C#Copy Code
vdrawobj.scriptCommand.polyline(); // begins a user action to draw a polyline
C#Copy Code
vdrawobj.scriptCommand.polyline(null,true,1); // begins a user action to draw a closed fitting spline
C#Copy Code
// draw a polyline using active color , linetype,layer etc properties, from 1,1 to 2,2 to 2,0 
//after this command is finished the object is not drawn on screen. 
//You can call the vdrawObj.redraw after adding an amount of commands 
vdrawobj.scriptCommand.polyline([[1,1,0],[2,2,0],[2,0,0]],true,0);  
setTimeout(vdrawObj.redraw);//post a redraw command
C#Copy Code
// draw a fitting spline using active color , linetype,layer etc properties, from 1,1 to 2,2 to 2,0 
//after this command is finished the object is not drawn on screen. 
In order to display it call vdrawObj.DrawEntity and <see cref="M:vdWebLibrary.vdrawObj.Refresh"/>  inside the user define callback .See example. 
 
function actionentityadded(vdraw, entity) { 
   vdraw.DrawEntity(entity); 
   setTimeout(vdraw.Refresh);//post a refresh command 
            } 
vdcanvas.scriptCommand.polyline([[1, 1, 0], [2, 2, 0], [2, 0, 0]], true, 1, actionentityadded);

Remarks

if passed parameters not exist or it is null then start a new user action and prompts the user to draw a polyline. If parameters are not null then a new polyline 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