# 70001371 Create a polyhatch in a non-XY plane

 Article 70001371 Type HowTo Product Engine Version 7 Date Added 7/23/2018 Fixed 7.7016.0.2 (7/23/2018) Submitted by Wayne R.

## Summary

How can I create a polyhatch in a non X/Y plane

## Solution

When creating a hatch the polycurves and the Hatch should be in the X/Y plane so if you have polylines in the SAME but not X/Y plane you need to "bring" them to the X/Y plane, create the polyhatch and then set them back to their plane. See the code:

```        private void Test()
{
vdDocument doc = vdFramedControl.BaseControl.ActiveDocument;
doc.New();

#region create 2 random polylines
// we will use two circles in order to get some random points from them to create the polylines.
vdCircle cir1 = new vdCircle(doc, new gPoint(3, 2), 5);
vdCircle cir2 = new vdCircle(doc, new gPoint(3, 2), 2);
Vector vec = new Vector(0.3, 0.7, -0.2); vec.Normalize();
cir1.ExtrusionVector = vec;
cir2.ExtrusionVector = vec;
// 2 circles are created in the same "random" plane

// get some points from these just to "have" two polylines
gPoints pts1 = cir1.geomMeasure(7); // points of 1st polyline
gPoints pts2 = cir2.geomMeasure(4); // points of 2nd polyline
#endregion

Matrix mat = new Matrix(); // this is the matrix of the plane that the circles belong to
mat.SetToViewDirection(vec, 0.0d);
Matrix invmat = new Matrix(mat.GetInvertion());

// create the curves for the polyhatch
vdPolyline pl = new vdPolyline(doc, pts1);

// vector should be perpendicular in the plane where the polyline is and can also calculated using CalculateNormal3P, like:
Vector vec2 = new Vector();
Vector.CalculateNormal3P(pl.VertexList[0] as gPoint, pl.VertexList[1] as gPoint, pl.VertexList[2] as gPoint, out vec2);
// in this case we already have it from the circle, as we set it above.

pl.ExtrusionVector = vec;
pl.Flag = VdConstPlineFlag.PlFlagCLOSE;
pl.Transformby(mat); // we need to bring these points to X/Y plane
pl.Update();

VectorDraw.Professional.vdCollections.vdCurves curves_Outer = new VectorDraw.Professional.vdCollections.vdCurves();

pl = new vdPolyline(doc, pts2);
pl.ExtrusionVector = vec;
pl.Flag = VdConstPlineFlag.PlFlagCLOSE;
pl.Transformby(mat); pl.Update(); // we need to bring these points to X/Y plane

VectorDraw.Professional.vdCollections.vdCurves curves_Inside = new VectorDraw.Professional.vdCollections.vdCurves();

//'create polyhatch
vdPolyhatch onehatch = new vdPolyhatch(doc);
onehatch.HatchProperties = new VectorDraw.Professional.vdObjects.vdHatchProperties(VectorDraw.Professional.Constants.VdConstFill.VdFillModeSolid);

onehatch.Transformby(invmat); // bring this to the plane where the circles are.