The AutoLisp Intermediate Tutorial


Entity DXF Group Codes


   All entities inside an AutoCAD drawing has DXF Group codes.  The group codes define the properties of each entity.  Each code inside the group is acutally an associtated list.  The group codes for a line may look something like this: 

((-1 . <Entity name: 3b40868>) (0 . "LINE") (5 . "BD") (100 . "AcDbEntity")     (67 . 0) (8 . "DIM") (100 . "AcDbLine") (10 200.25 316.75 0.0)
  (11 242.25 316.75 0.0) (210 0.0 0.0 1.0))

Where:

Group code -1 is the name of the entity. 

Group code 0 is the type of entity.

Group code 8 is the layer name.

Group code 10 is the start point of the line.

Group code 11 is the end point of the line.

The group codes for a circle may look something like this:

((-1 . <Entity name: 3b40cf0>) (0 . "CIRCLE") (5 . "146") (100 . "AcDbEntity") (67 . 0) (8 . "HOL") (100 . "AcDbCircle") (10 163.135 367.479 0.0)            (40 . 2.56277) (210 0.0 0.0 1.0))

Where:

Group code -1 is the name of the entity. 

Group code 0 is the type of entity.

Group code 8 is the layer name.

Group code 10 is the center of the circle.

Group code 40 is the radius of the circle.


How do you list the codes for an entity?   Type this at the command line, press enter, and select an entity.

(entget(car(entsel))) 

Entsel selects the entity, car gets the entity name from entsel, and entget returns the Group Codes of the entity.


What are the numbers in the group code for?  They aide in extracting data from the group codes.  Take for instance this code:

(setq entList(entget (car (entsel))))

If I selected a circle, this code would set entList to something like this:

((-1 . <Entity name: 3b40cf0>) (0 . "CIRCLE") (5 . "146") (100 . "AcDbEntity") (67 . 0) (8 . "HOL") (100 . "AcDbCircle") (10 163.135 367.479 0.0)            (40 . 2.56277) (210 0.0 0.0 1.0))

If I wanted to extract data from this group code list I would simply type:

(assoc 40 entList)  ;would return 2.56277

(assoc 0 entList)  ;would return "CIRCLE"

(assoc 10 entList)  ;would return (163.135 367.479 0.0)

(assoc 8 entList)  ;would return "HOL"

An associated list can make extraction a very easy thing to accomplish.


For a list of the DXF Group Codes and to find out which entities they apply to, click here.


Back to AutoLisp Intermediate Tutorial - Selecting Entities

AutoLisp Tutorial Home