Custom Hatch Pattern in CADopia


Custom Hatch Pattern

In general, you can hatch entities in a drawing using the default hatch patterns included in the CADopia software. However, CADopia lets you create custom hatch pattern if you need one. There is no limit to the number of hatch patterns you can define.

You can create a new hatch pattern file and include the path of the pattern file in the File Search Path. In this article we will show you how to add a new hatch pattern. Once we create a new pattern we have to create a corresponding .SLD file to view the pattern in the Hatch Pattern dialog box.

The hatch pattern definition consists of the following two parts: Header Line and the Hatch Descriptors.

Header Line:

The header line consists of an asterisk (*) followed by the name of the hatch pattern.
The hatch description is optional and it follows the hatch name. A comma separates the hatch
name and the hatch description. The general format of the header line is:

*HATCH Name [, Hatch Description]

Where *—————————Asterisk
HATCH Name——–Name of hatch pattern.
Hatch Description—-Description of hatch pattern.
The description can be any text that describes the hatch pattern. It can be omitted, in which case,
a comma should not follow the hatch pattern name.

Example – *DASH45, Dashed lines at 45-degree.
Where DASH45 —————Hatch name.
Dashed lines at 45-degree —————-Hatch description.

Hatch Descriptors:

The hatch descriptors consist of one or more lines that contain the definition of the hatch lines.
The general format of the hatch description is:

Angle, X-origin, Y-origin, D1, D2 [, Dash Length…….]
Where Angle —————– Angle of hatch lines.
X-origin ———————— X coordinate of hatch line.
Y-origin ———————— Y coordinate of hatch line.
D1 —————————— Displacement of second line (Delta – X).
D2 —————————— Displacement between hatch lines (Delta – Y).
Length ————————- Length of dashes and spaces (Pattern line definition).

Example
45, 0, 0, 0, 0.5, 0.5,-0.125, 0,-0.125
Where 45 ———————- Angle of hatch line.
0 ——————— X-Origin.
0 ——————— Y-Origin.
0 ——————— Delta – X.

CADopia

The remaining lines are generated by offsetting the first hatch line by a distance specified by
delta-X and delta-Y. In Figure 2 (a), the first hatch line starts from the point with the
coordinates X = 0 and Y = 0. In Figure 2 (b), the first line of hatch starts from a point with the
coordinates X=0 and Y=0.25.

CADopia

CADopia

Delta-X and Delta-Y:

Delta-X is the displacement of the offset line in the direction in which the hatch lines are
generated. For example, if the lines are drawn at a 0-degree angle and delta – X= 0.5, the
offset line will be displaced by a distance delta-X (0.5) along the 0-angle direction. Similarly,
if the hatch lines are drawn at a 45-degree angle, the offset line will be displaced by a distance
delta-X (0.5) along a 45-degree direction (Fig 3 a). Delta-Y is the displacement of the offset
lines measured perpendicular to the hatch lines. For example, if delta-Y = 1.0, the space between
any two hatch lines will be 1.0 (Fig 3 b).

CADopia

CADopia

Next, we write a hatch pattern definition for the hatch pattern shown in the Fig. 4 (a), with the following specifications:

Name of the hatch pattern = HATCH3

Vertical height of the triangle = 0.5

Horizontal length of the triangle = 0.5
Vertical distance between the triangle = 0.5
Horizontal distance between the triangles = 0.5

Each triangle in this hatch pattern consists of the following three elements: a vertical line, a horizontal line, and a line inclined at 45-degree.

After creating it we will make the corresponding .sld file and will also show how to specify a new path for Hatch pattern files.

CADopia

Step 1:

Defining specifications for vertical line.
For the vertical line, the specifications are( Fig. 4(b)):

Hatch angle = 90-degree
X-origin = 0
Y-origin = 0
Delta-X (D1) = 0
Delta-Y (D2) = 1.0
Dash length = 0.5
Space = 0.5

Substitute the values from the vertical line specification in various fields of the hatch
descriptor to get the following line:

90,0,0,0,1,.5,-.5
Where 90 ——————— Hatch angle.
0 ———————– X – origin.
0 ———————– Y – origin.
0 ———————– Delta – X.
1 ———————– Delta – Y.
.5 ———————- Dash (pen down).
-.5 ———————- Space (pen up).

CADopia

Step 2:

Defining specifications of horizontal line.
For the horizontal line (Fig. 5), the specifications are:

Hatch angle = 0-degree
X-origin = 0
Y-origin = 0.5
Delta-X (D1) = 0
Delta-Y (D2) = 1.0
Dash length = 0.5
Space = 0.5

For the horizontal line, the angle is 0 – degree, whereas for the vertical line, the angle is
90-degrees. Substitute the values from the vertical line specification to obtain the following
line.

0,0, 0.5,0,1,.5,-.5
Where
0 ——————— Hatch angle.
0 ———————– X – origin.
0.5 ———————– Y – origin.
0 ———————– Delta – X.
1 ———————– Delta – Y.
.5 ———————- Dash (pen down).
-.5 ———————- Space (pen up).

CADopia

Step 3:

Defining specifications of the inclined line.

This line is at an angle; therefore, you need to calculate the distances delta – X (D1) and delta-Y
(D2), the length of the dashed line, and the length of the blank space. Fig 6 shows the
calculations to find these values.

Hatch angle = 45-degree
X – Origin = 0
Y – Origin = 0
Delta – X (D1) = 0.7071
Delta – Y (D2) = 0.7071
Dash length = 0.7071
Space = 0.7071

After substituting the values in the general format of the hatch description, you get the
following line:

45,0,0, .7071, .7071,.7071,-.7071

Where
45 ———————— Hatch angle.
0 ———————— X-origin.
0 ———————— Y-origin.
.7071 ——————– Delta – X.
.7071 ——————– Delta – Y.
.7071 ——————– Dash (pen down).
-.7071 ——————– Space (pen up).

Step 4:

Loading the hatch pattern.

Now you can enter the values in a separate hatch file and save it, let’s call it CADopia.pat.

The following is a listing of the CADopia.pat file, after adding the hatch pattern definition :

*HATCH3, Triangle Hatch:
90,0,0,0,1,.5,-.5
0,0,0.5,0,1,.5,-.5
45,0,0,.7071,.7071,.7071,-.7071

Whenever we enter a hatch pattern name for hatching, CADopia looks for that file name in the
File Locations–>System–>Support Files Search Path under Tools >Options menu. You can specify a
new path and folder to store your hatch files.

Let us create a new folder “Hatch” in C drive. Save the CADopia.pat file with hatch pattern
HATCH3 definition in the Hatch folder. Now, choose Options from the Tools menu to display the
Options dialog box with File Locations tab active as shown below. Highlight Support Files Search
Path and click on New, then browse to C:\Hatch and add it to the Search Path. Click OK to exit
the File Locations dialog.

CADopia

To view the pattern image for the new hatch, create the .sld file for this hatch pattern.

Use the following steps:

  1. Open a new drawing make a rectangle and hatch it with HATCH3 pattern.
  2. Zoom the hatch area within the rectangle in such a way that a large number of triangles is visible.
  3. Now, use the command “MSLIDE” to create a new .sld file with the name HATCH 3.sld.
  4. Save the HATCH3.sld file within the folder Hatch.

CADopia

Now you will be able to view the pattern image in the “Boundary Hatch > Pattern”.
You can change the scale and the angle of the hatch from the pattern properties.

CADopia

You can download the HATCH3.sld file along with the cadopia.pat file containing the HATCH3 pattern definition which you can directly use.

CADopia

We hope you have found this article useful. If you have questions or comments, please send them
to support@cadopia.com.