Modifying an Entity

The entmod function modifies an entity. It passes a list that has the same format as a list returned by entget but with some of the entity group values (presumably) modified by the application. This function complements entget. The primary mechanism by which an AutoLISP application updates the database is by retrieving an entity with entget, modifying its entity list, and then passing the list back to the database with entmod.

The following code fragment retrieves the definition data of the first entity in the drawing and changes its layer property to MYLAYER.

(setq en (entnext))	 ; Sets en to first entity name 
						; in the drawing.
(setq ed (entget en))   ; Sets ed to the entity data 
						; for entity name en.
(setq ed 
  (subst  (cons 8 "MYLAYER")
	(assoc 8 ed)		; Changes the layer group in ed.
	ed				; to layer MYLAYER.
(entmod ed)			 ; Modifies entity en's layer in 
						; the drawing.

There are restrictions on the changes to the database that entmod can make; entmodcannot change the following:

Other restrictions apply when modifying dimensions and hatch patterns.

AutoCAD must recognize all objects (except layers) that the entity list refers to. The name of any text style, linetype, shape, or block that appears in an entity list must be defined in the current drawing before the entity list is passed to entmod. There is one exception: entmod accepts new layer names.

If the entity list refers to a layer name that has not been defined in the current drawing, entmod creates a new layer. The attributes of the new layer are the standard default values used by the New option of the AutoCAD LAYER command.

The entmod function can modify subentities such as polyline vertices and block attributes.

If you use entmod to modify an entity in a block definition, this affects all INSERT or XREF references to that block. Also, entities in block definitions cannot be deleted by entdel.