%%PageItemTitle%%

VectorDraw Web Library

JsPropertiesExtractor Send comments on this topic.
AddBlock Method
See Also  Example
vdWebLibrary Namespace > vdrawObj Class : AddBlock Method
blockname
The name of the block to be added.
originPoint
The origin point of the block to be added.
Add a block object in the blocks collection of the document. If the blockname already exists, the already created block is returned.

Syntax

JScript 
public function AddBlock( 
   blockname : String,
   originPoint : Object
) : Object;

Parameters

blockname
The name of the block to be added.
originPoint
The origin point of the block to be added.

Return Value

The created block object.

Example

For example we create a new block which contains two lines and then we insert it using the AddBlockSymbol method.
C#Copy Code
  
var blk = vdcanvas.AddBlock("myblock"); 
//add a new line to block 
                var line1 = vdcanvas.AddLine([0, 0, 0],[2, 0, 0],false,blk.Entities); 
 
//we can set the line color to be 'byblock'(it will get the color of the insertBlock, else it will get the vdcanvas.GetActivePenColor() 
line1.PenColor =  vdConst.colorFromString("byblock"); 
 
//add an other new line to block 
                var line2 = vdcanvas.AddLine([1, -1, 0],[1, 1, 0],false,blk.Entities); 
 
//we can set the line color to be 'byblock'(it will get the color of the insertBlock, else it will get the vdcanvas.GetActivePenColor() 
line2.PenColor =  vdConst.colorFromString("byblock"); 
 
//we insert the block  
vdcanvas.AddBlockSymbol("myblock",[0,0,0],1.0,0,true);

See Also