Below is the entity group code for a line:
(-1.<Entity name: 60000014>)
(0."LINE")
(8."0")
(10 1.0 2.0 0.0)
(11 6.0 6.0 0.0)

Table part group code

Group code straight line Arc
8 Layer name Layer name
10 Starting point coordinates Center coordinates
11 End point coordinates .........
40 ......... radius
50 ......... Starting angle
51 ......... End angle
210 Extension direction Extension direction

2 programming method

The program first calls the gettfiled() function to create an NC file (the file has a .3B extension), and then uses the ssget() function to define the entity selection set (selected by the user in the processing order), which is broken into "Line" and "Arc" two types (after research found that for v12.0, the graphics entity is decomposed to the end are Line and Arc, such as Fit fitting pline after breaking the Arc, spline fitting pline is broken after the line Etc.), so the core of the program is for line and Arc. The program is transferred to the next entity to determine whether it is line or Arc. After the split, the geometric data is extracted according to the group code of line or Arc, and finally a string "B XX B YY BJGZ" is formed, and the character is added to the NC file. Go in, then call in an entity to perform a loop calculation, so that the NC files are added line by line until the entity is edited.

For straight lines, the starting and ending coordinates can be extracted with 10 and 11 sets of codes, and then the origin is changed to the starting point, at which point XX and YY are the end point coordinates. Let dx1 and dx2 be the absolute values ​​of XX and YY respectively, then when dx1>dy1, G=G x and J=dx1, otherwise, G=G y and J=dy1. For arcs, the center, radius, starting angle, and ending angle can be extracted using 10, 40, 50, and 51 sets of codes. One of the problems with arcs is the calculation of the projection length J, as shown in Figure 3.

The J calculation of the arc is divided into three cases (Fig. 3) for 1J=|Q x -Zh x | or J=|Q y -Zh y | (Q: start point, Zh: end point). For 2, move the origin to point Q, where J=|Q x +Zh x | or J=|Q y +Zh y |. For 3, move the origin to Q 1 and Q 2 to calculate Q 1 A' and Q 2 B': Q 1 A'=|Q x | or |Q y |, Q 2 B'=
|Zh x | or |Zh y |, then J=Q 1 A'+Q 2 B'+D.

Previous page next page

Posted on