A group is just a bunch of DXF entities tied together. All entities of a group has to be on the same layout (model space or any paper layout but not block). Groups can be named or unnamed, but in reality an unnamed groups has just a special name like '*Annnn'. The name of a group has to be unique in the drawing. Groups are organized in the main group table, which is an Drawing.groups of the class Drawing.

Group entities have to be in model space or any paper layout but not in a block definition!

class DXFGroup
DXFAttr Version Description
description R13 group description (string)
unnamed R13 1 for unnamed, 0 for named group (int)
selectable R13 1 for selectable, 0 for not selectable group (int)
The group name is not stored in the GROUP entity, it is stored in the DXFGroupTable object.

Iterate over all DXF entities in this group as instances of GraphicEntity or inherited (LINE, CIRCLE, …).


Returns the count of DXF entities in this group.


Returns True if item is in this group else False. item has to be a handle string or an object of type GraphicEntity or inherited.


Generator over all entity handles in this group.


Get name of the group as string.


Context manager which yields all the group entities as standard Python list:

with group.edit_data() as data:
   # add new entities to a group
   data.append(modelspace.add_line((0, 0), (3, 0)))
   # remove last entity from a group

Set entities as new group content, entities should be iterable and yields instances of GraphicEntity or inherited (LINE, CIRCLE, …).


Append entities to group content, entities should be iterable and yields instances of GraphicEntity or inherited (LINE, CIRCLE, …).


Remove all entities from group.


Remove invalid handles from group. Invalid handles: deleted entities, entities in a block layout (but not implemented yet)


There only exists one group table in each drawing, which is accessible by the attribute Drawing.groups.

class DXFGroupTable

Iterate over all existing groups as (name, group) tuples. name is the name of the group as string and group is an object of type DXFGroup.


Generator over all existing groups, yields just objects of type DXFGroup.


Returns the count of DXF groups.


Returns True if a group name exists else False.


Returns the group name as DXFGroup object. Raises DXFKeyError if no group name exists., description="", selectable=1)

Creates a new group, returns a DXFGroup object. If name is None an unnamed group is created, which has an automatically generated name like '*Annnn'. description is the group description as string and selectable defines if the group is selectable (selectable=1) or not (selectable=0).


Delete group. group can be an object of type DXFGroup or a group name.


Delete all groups.


Removes invalid handles in all groups and empty groups.