70001511 Add polyhatch command in WebControl

Article 70001511
Type Wish
Product WebJS
Version 8001
Date Added 4/3/2019
Fixed 8.8002.0.4 (5/8/2019)
Submitted by Davide Andreoli


Add a new polyhatch command in WebControl


In version 8002.0.4 AddPolyHatch method has been added which adds a new vdPolyhatch in the document.

Method: AddPolyHatch(object[] curves, object[] outlines, bool drawit, object entities)


curves:An array of vdfigures that they will be hatched or an array of points
outlines: Used for DrawBoundary property.An array of vdfigures or an array of points or null in order to use the outlines of the objects.
drawit:Defines if the vdPolyhatch object will be drawn.
entities:The entities collection where the polyhatch will be added. This can be the entities of layout or a block.

Example1: In the first example we create a new polyline,arc,rectangle,circle and ellipse and then we will add them in the AddPolyhatch method.
We do not set any outlines so the outlines of the objects will be used.

           var circle = vdcanvas.AddCircle([-3, -3, 0], 1, false);
           var rect = vdcanvas.AddRect([-7, 6, 0], [-1, 10, 0], false);
           var arc = vdcanvas.AddArc(vdgeo.newpoint(-20, 0, 0), 5, vdgeo.DegreesToRadians(0), vdgeo.DegreesToRadians(135), false);
           var ellipse = vdcanvas.AddEllipse(vdgeo.newpoint(10, 10, 0), 10, 4, vdgeo.DegreesToRadians(90), vdgeo.DegreesToRadians(0), vdgeo.DegreesToRadians(360), false);
           var vertexes = [vdgeo.newvertex(-2, -2, 0, 0), vdgeo.newvertex(2, 1, 0, 0), vdgeo.newvertex(5, 5, 0, 0), vdgeo.newvertex(2, 3, 0, 0)];
           var pline = vdcanvas.AddPolyline(vertexes, false);
           pline.SPlineFlag = 0;// standad polyline
           pline.Flag = 1;// closed polyline.By default Flag = 0 which is not be closed.
           vdcanvas.UpdateFig(pline);//update the figure in order to get the changes
           var ph = vdcanvas.AddPolyHatch([arc, ellipse, circle, pline, rect], null, true);          
           ph.HatchProperties = vdcanvas.createNewHatchProperties("u20", vdConst.colorFromString("255,255,0,255"), vdConst.colorFromString("255,0,0,255"), 1.0, 0.0);
           ph.HatchProperties.DrawBoundary = true;//By default is false so the boundary is not be drawn
           vdcanvas.UpdateFig(ph);//update the figure in order to get the changes
           vdcanvas.DrawEntity(ph);// draw the figure on the screen
Example2: In the second example we create an array of eight points which represent two rectangles and then we will add them in the AddPolyhatch method.
We now set outlines the same points of the rectangles.
           var a1, a2, a3, a4, b1, b2, b3, b4; //create the new eight variables
           a1 = [0, 0, 0]; // set values for the first rectangle
           a2 = [1, 0, 0];
           a3 = [1, 1, 0];
           a4 = [0, 1, 0];
           b1 = [2, 0, 0]; // set values for the second rectangle
           b2 = [3, 0, 0];
           b3 = [3, 1, 0];
           b4 = [2, 1, 0];
           vdcanvas.SetActiveHatchProperties(vdcanvas.createNewHatchProperties('solid', vdConst.colorFromString("255,0,0"), vdConst.colorFromString("0,0,255")))//set active hatch properties      
           var ph = vdcanvas.AddPolyHatch([[a1, a2, a3, a4], [b1, b2, b3, b4]], [[a1, a2, a3, a4], [b1, b2, b3, b4]], true);
           ph.HatchProperties.DrawBoundary = true; //By default is false so the boundary is not be drawn
           vdcanvas.DrawEntity(ph); // draw the figure on the screen   

Send comments on this topic.