A group is just a bunch of DXF entities tied together. All entities of a group
has to be in the same layout (modelspace or any paperspace 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 group table, which is stored as attribute
groups in the
Group entities have to reside in the modelspace or an paperspace layout but not in a block definition!
The group name is not stored in the GROUP entity, it is stored in the
group description (string)
1 for unnamed, 0 for named group (int)
1 for selectable, 0 for not selectable group (int)
__iter__() → Iterator[ezdxf.entities.dxfentity.DXFEntity]¶
Iterate over all DXF entities in
DXFGroupas instances of
DXFGraphicor inherited (LINE, CIRCLE, …).
Returns entities by standard Python indexing and slicing.
__contains__(item: Union[str, ezdxf.entities.dxfentity.DXFEntity]) → bool¶
Trueif item is in
DXFGroup. item has to be a handle string or an object of type
edit_data() → list[DXFEntity]¶
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 data.pop()
set_data(entities: Iterable[ezdxf.entities.dxfentity.DXFEntity]) → None¶
Set entities as new group content, entities should be an iterable
DXFGraphicor inherited (LINE, CIRCLE, …). Raises
DXFValueErrorif not all entities be on the same layout (modelspace or any paperspace layout but not block)
extend(entities: Iterable[ezdxf.entities.dxfentity.DXFEntity]) → None¶
Add entities to
DXFGroupwithout immediate verification!
Validation at DXF export may raise a
clear() → None¶
Remove all entities from
DXFGroup, does not delete any drawing entities referenced by this group.
Returns the count of DXF groups.
Iterate over all existing groups as (name, group) tuples. name is the name of the group as string and group is an
Trueif a group name exist.
get(name: str) → DXFGroup¶
Returns the group name. Raises
DXFKeyErrorif group name does not exist.
groups() → Iterator[ezdxf.entities.dxfgroups.DXFGroup]¶
Iterable of all existing groups.
new(name: Optional[str] = None, description: str = '', selectable: bool = True) → ezdxf.entities.dxfgroups.DXFGroup¶
Creates a new group. If name is
Nonean unnamed group is created, which has an automatically generated name like “*Annnn”. Group names are case-insensitive.
- name – group name as string
- description – group description as string
- selectable – group is selectable if
delete(group: Union[ezdxf.entities.dxfgroups.DXFGroup, str]) → None¶
Delete group, group can be an object of type
DXFGroupor a group name as string.
Delete all groups.
audit(auditor: Auditor) → None¶
Removes empty groups and invalid handles from all groups.