How to create a hatch on the basis of an existing entity?
- Add the 
usingdirective with theCADImportandCADImport.FaceModulenamespaces. 
using CADImport;
using CADImport.FaceModule;
More information about CADPictureBox
The CADPictureBox class is the basic implementation of the control element for displaying vector drawings. Visually CADPictureBox includes only area for drawing visualization and can be extended by the required control elements in the project under development.
To get more information about the CAD .NET controls, see What controls does CAD .NET have?
- Use the control element of the 
CADPictureBoxclass:- Set the 
Locationproperty asnew Point(10, 30). - Set the 
BackColorproperty asColor.Black. - Set the 
Sizeproperty asnew Size(995, 500). - Finally, add it to the form.
 
 - Set the 
 
...
CADPictureBox pictureBox1 = new CADPictureBox(){
  Location = new Point(10, 30),
  BackColor = Color.Black,
  Size = new Size(995, 500),
}
public Form1()
  {
    Controls.Add(pictureBox1);
    InitializeComponent();
  }   
- Add a new button. Name it 
AddAHatch. Then create theAddAHatch_Clickfunction to create a hatch on the basis of an existing entity by click. 
private void AddAHatch_Click(object sender, EventArgs e)
- Create a new instance of the 
CADImageclass:- Call 
InitializeSectionto create theCADobject manually. - Set the 
Backgroundproperty asColor.Azure. - Set the 
CurrentLayoutproperty asvDrawing.Layouts[0]. 
 - Call 
 
  CADImage vDrawing = new CADImage();
  vDrawing.Converter.InitializeSections();
  vDrawing.BackgroundColor = Color.Azure;
  vDrawing.CurrentLayout = vDrawing.Layouts[0];
- Create an instance of the 
CADEllipseclass:- Add this entity to the drawing with the 
AddEntitymethod. - Set the 
Pointproperty asnew DPoint(10, 10, 0). - Set the 
Radiusproperty as10. - Set the 
Ratioproperty as1.5. - Set the 
RadPtproperty asnew DPoint(25, 25, 0). - Set the 
Colorproperty asColor.Maroon. - Set the 
LineWeightproperty as5. - Use the 
Loadsmethod to fill the internal data of the entity to prepare it for drawing. 
 - Add this entity to the drawing with the 
 
  CADEllipse vEllipse = new CADEllipse();
  vDrawing.CurrentLayout.AddEntity(vEllipse);
  vEllipse.Point = new DPoint(10, 10, 0);
  vEllipse.Radius = 10;
  vEllipse.Ratio = 1.5;
  vEllipse.RadPt = new DPoint(25, 25, 0);
  vEllipse.Color = Color.Maroon;
  vEllipse.LineWeight = 5;
  vDrawing.Converter.Loads(vEllipse);
The following picture illustrates the ellipse without a hatch.
- Create an instance of the 
CAD2DEllipseclass that repeats thevEllipseoutline: 
  CAD2DEllipse v2dEllipse = new CAD2DEllipse();
  v2dEllipse.CenterPoint = vEllipse.Point;
  v2dEllipse.MajorPoint = vEllipse.RadPt;
  v2dEllipse.Radius = vEllipse.Ratio;
- Create an instance of the 
CAD2DBoundaryclass. Addv2dEllipseto the boundary list. 
  CAD2DBoundaryList vBoundaryList = new CAD2DBoundaryList();
  vBoundaryList.Add(v2dEllipse);
- Create an instance of the 
CADCurvePolygonclass:- Add this entity to the current layout of 
vDrawingusing theAddEntitymethod. - Add 
vBoundaryListtoBoundaryData. - Set the 
Colorproperty asColor.Green. - Use the 
Loadsmethod to fill the internal data of the entity to prepare it for drawing. 
 - Add this entity to the current layout of 
 
  CADCurvePolygon vHatch = new CADCurvePolygon();
  vDrawing.CurrentLayout.AddEntity(vHatch);
  vHatch.BoundaryData.Add(vBoundaryList);
  vHatch.Color = Color.Green;
  vDrawing.Converter.Loads(vHatch); 
- Use the 
GetExtentsmethod to recalculate drawing extents. 
vDrawing.GetExtents();
- Declare the local variable 
vRectand specifyRectangleFas its type. This variable stores four floating values that represent the location and size of a CAD file. Use the following code to fit the CAD file topictureBox1. Finally, render the result with theDrawmethod. 
RectangleF vRect;
double vRatio = (double)(vDrawing.AbsHeight * pictureBox1.ClientSize.Width)/ (vDrawing.AbsWidth * pictureBox1.ClientSize.Height);
if (vRatio > 1)
  vRect = new RectangleF(0, 0, (float)(pictureBox1.ClientSize.Width / vRatio), (float)pictureBox1.ClientSize.Height);
else
  vRect = new RectangleF(0, 0, (float)pictureBox1.ClientSize.Width, (float)(pictureBox1.ClientSize.Height * vRatio));
vDrawing.Draw(pictureBox1.CreateGraphics(), vRect);
The following picture illustrates the result.
You have created the function to create a hatch on the basis of an existing entity.
The full code listing:
...
using CADImport;
using CADImport.FaceModule;
namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        CADPictureBox pictureBox1 = new CADPictureBox()
        {
            Location = new Point(10, 30),
            TabIndex = 10,
            BackColor = Color.Black,
            Size = new Size(995, 500)
        };
        public Form1()
        {
            Controls.Add(pictureBox1);
            InitializeComponent();
        }   
        private void AddAHatch_Click(object sender, EventArgs e)
        {
            CADImage vDrawing = new CADImage();
            vDrawing.Converter.InitializeSections();
            vDrawing.BackgroundColor = Color.Azure;
            vDrawing.CurrentLayout = vDrawing.Layouts[0];
            // Creating an ellipse
            CADEllipse vEllipse = new CADEllipse();
            vDrawing.CurrentLayout.AddEntity(vEllipse);
            vEllipse.Point = new DPoint(10, 10, 0);
            vEllipse.Radius = 10;
            vEllipse.Ratio = 1.5;
            vEllipse.RadPt = new DPoint(25, 25, 0);
            vEllipse.Color = Color.Maroon;
            vEllipse.LineWeight = 5;
            vDrawing.Converter.Loads(vEllipse);
            //Creating v2dEllipse that repeats the vEllipse outline. .
            CAD2DEllipse v2dEllipse = new CAD2DEllipse();
            v2dEllipse.CenterPoint = vEllipse.Point;
            v2dEllipse.MajorPoint = vEllipse.RadPt;
            v2dEllipse.Radius = vEllipse.Ratio;
            // Adding v2dEllipse to the Boundary list
            CAD2DBoundaryList vBoundaryList = new CAD2DBoundaryList();
            vBoundaryList.Add(v2dEllipse);
            vBoundaryList.BoundaryType = 1;
            // Creating a hatch
            CADCurvePolygon vHatch = new CADCurvePolygon();
            vDrawing.CurrentLayout.AddEntity(vHatch);
            vHatch.BoundaryData.Add(vBoundaryList);
            vHatch.Color = Color.Green;
            vDrawing.Converter.Loads(vHatch);          
            vDrawing.GetExtents();
            // adjusting visualization sizes to the control area:
            RectangleF vRect;
            double vRatio = (double)(vDrawing.AbsHeight * pictureBox1.ClientSize.Width) / (vDrawing.AbsWidth * pictureBox1.ClientSize.Height);
            if (vRatio > 1)
                vRect = new RectangleF(0, 0, (float)(pictureBox1.ClientSize.Width / vRatio), (float)pictureBox1.ClientSize.Height);
            else
                vRect = new RectangleF(0, 0, (float)pictureBox1.ClientSize.Width, (float)(pictureBox1.ClientSize.Height * vRatio));
            vDrawing.Draw(pictureBox1.CreateGraphics(), vRect);
        }
    }
}