Prod.: Engine, ver.: 6, ID: 60001069, HowTo : How can I calculate the Area and the Length of a vdPolyHatch object

HowTo : How can I calculate the Area and the Length of a vdPolyHatch object

Article60001069
TypeHowTo
ProductEngine
Version6
Date Added1/29/2010
Submitted bySami Tainio
Keywords

Subject

How can I calculate the Area and the Length of a vdPolyHatch object

Summary

How can I calculate the Area and the Length of a vdPolyHatch object

Solution

You can calculate the area and the length of a complex vdPolyhatch with a code like :

private void button1_Click(object sender, EventArgs e)
{
   vdFramedControl1.BaseControl.ActiveDocument.Open(
@"c:\321\Hatch\test.vdml"
); // I have used a test drawing that containd a hatch
   VectorDraw.Professional.vdFigures.
vdPolyhatch pHatch = vdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.Entities[4] as VectorDraw.Professional.vdFigures.vdPolyhatch
;// this is the vdPolyHatch object that I need to calculate the length and area
   if (pHatch == null) return
;
   double
area = pHatch.ToMesh(0).Area();
   double
length1 =0.0d;

   foreach (VectorDraw.Professional.vdCollections.vdCurves curves in pHatch.PolyCurves)
   {
      foreach (VectorDraw.Professional.vdFigures.vdCurve curve in
curves)
      {
         length1 += curve.Length();
      }
   }
   this.Text = "Area: " + area.ToString(); +" Length: "
+ length1.ToString();
}