Method AddBlock
- Namespace
- vdWebLibrary
- Assembly
- JsPropertiesExtractor.dll
AddBlock(string, object)
Add a block object in the blocks collection of the document. If the blockname already exists, the already created block is returned.
public object AddBlock(string blockname, object originPoint)
Parameters
blocknamestringThe name of the block to be added.
originPointobjectThe origin point of the block to be added.
Returns
- object
The created block object.
Examples
For example we create a new block which contains two lines and then we insert it using the AddBlockSymbol method.
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);