| Article | 70001513 |
| Type | HowTo |
| Product | WebJS |
| Date Added | 4/4/2019 12:00:00 AM |
| Fixed | 8.8002.0.2 (4/4/2019 12:00:00 AM) |
| Submitted by | Kostas Androulakis |
Summary
How to create simple polyhatch objects in WebControl
Solution
In the example bellow we create a new object named polyhatch which contains two rectangles.The points of the first rectangle are a1,a2,a3,a4 ([0,0,0],[1,0,0],[1,1,0],[0,1,0]) and the points of the
second rectangle are b1,b2,b3,b4 ([2, 0, 0],[3, 0, 0],[3, 1, 0],[2, 1, 0]).Using this way you are able to create several simple polyhatche objects.
var a1, a2, a3, a4, b1, b2, b3, b4;//create the new eight variables
a1 = [0, 0, 0];// set values to the variables
a2 = [1, 0, 0];
a3 = [1, 1, 0];
a4 = [0, 1, 0];
b1 = [2, 0, 0];
b2 = [3, 0, 0];
b3 = [3, 1, 0];
b4 = [2, 1, 0];
var polyhatch = {
_t:17, // the code type of the polyhacth object
Layer : vdcanvas.GetDocument().ActiveLayer, //set to the polyhatch the active layer
PenColor : vdConst.cloneColor(vdcanvas.GetActivePenColor()), //set to the polyhatch the active pen color
HatchProperties: vdcanvas.createNewHatchProperties("u20",vdConst.colorFromString("255,255,0,255"), vdConst.colorFromString("255,0,0,255"),1.0, 0.0), //hatchPattern name,hatch background color,hatch fron color,scale,angle
Curves: //set the variables to the curves of the hatch
{
Items:
[
{
Items://the points of the first rectangle
[
a1,
a2,
a3,
a4,
a1,
],
},
{
Items://the points of the secondrectangle
[
b1,
b2,
b3,
b4,
b1,
],
}
],
},
OutLines:// for the draw boundary property
{
Items:
[
{
Items:
[
a1,
a2,
a3,
a4,
a1,
],
},
{
Items:
[
b1,
b2,
b3,
b4,
b1,
],
},
],
},
};
vdcanvas.scriptCommand.RegisterFigure(polyhatch); //Add the passed figure to the active layout of the selected document and set a new HandleId for the figure.
setTimeout(vdcanvas.redraw);//post a redraw in order to display the new object
