CAD .NET. Aan de slag

CAD .NET. Aan de slag

Getting Started

Inherited classes structure is the basis of the CAD .NET library interface. You can find short descriptions of the most important classes below.

The CADImage class defines the drawing object. All available drawing data can be received via properties of this class. To create a new drawing it is necessary to create and initialize the CADImage object:

CADImage cadImage = new CADImage();
cadImage.InitialNewImage();

When this code is implemented a new drawing is ready for entities adding.

The library includes the CADImage derived classes that must be used only to import drawings of the corresponding format:

  • DWGImage - to import DWG drawings
  • CGMImage - to import CGM drawings
  • HPGLImage - to import HPGL/2 drawings
  • GBRImage - to import Extended Gerber (RS-274X) drawings
  • CADRasterImage - to import raster images and metafiles

The basic CADImage class is used to import DXF drawings.

While importing we recommend to use the CADImage.CreateImageByExtension function to create the required class automatically (it is defined by the text parameter extension). The next code automatically initializes cadImage as the class object of the required format (DWGImage) and then imports the specified drawing.

CADImage cadImage = CADImage.CreateImageByExtension(@"d:/1.dwg");
cadImage.LoadFromFile(@"d:/1.dwg");

It is unnecessary to implement the initialization method while importing the existing drawing.

The CADConverter class contains drawing settings as well as entries related to any existing drawing objects. Such nonvisual objects as layers, blocks and styles are stored in the CADConverter object. Each drawing has an only CADConverter object access to which is carried out via the CADImage.Converter. When any new object is added or any existing one is edited, a new/edited object must be loaded to CADConverter: :

cadImage.Converter.Loads(changedObject);

The CADEntity class is the basic entity class of the drawing (in other words, class of visual entities) as well as of other objects (e.g. layers and blocks). Each entity has its own set of properties and it allows users to access graphical drawing data more efficiently.

The CADEntityCollection class presents a collection of entities (CADEntity objects and inherited classes). Access to entity members can be carried out not only by index but also by Handle (a unique identifier for each entity).

The CADLayout class is the CADEntity derived class and presents a nonvisual layout object where entities are located. CAD .NET groups entities according to the layouts where they are located. Layout entities are contained in CADLayout.Entities that is the object of CADEntityCollection.

The CADImage.Layouts collection contains all drawing layouts while CADImage.CurrentLayout provides access to the current drawing layout, i.e. to the layout that will be visualized.

To draw the conclusion, here’s an example showing how to create a new drawing and add the CADLine entity (a line) to it:

CADImage cadImage = new CADImage();
cadImage.InitialNewImage();

CADLine vLine = new CADLine();
vLine.Point = new DPoint(80, 100, 0);
vLine.Point1 = new DPoint(150, 150, 0);
vLine.Color = Color.Blue;
vLine.LineWeight = 0.3;

cadImage.Converter.Loads(vLine);
cadImage.CurrentLayout.AddEntity(vLine);

When this code is processed, the current drawing layout can be visualized with the help of the CADImage.Draw method.

The source code of the demo projects is available in the set of the compilable version of the CAD .NET library. To receive the link for library downloading fill in the form please or send an e-mail at info@cadsofttools.com.

E-mailadres:*

Naam (optioneel):

Bericht (optioneel):



*

Als u geen berichten van ons meer wilt ontvangen, stuur dan een e-mail naar info@cadsofttools.com.