entmake
(entmake data)
The entmake function generates a new drawing entity (a basic entity or a complex object such as a polyline or a block insertion) in the current drawing database and displays it in the current drawing.
Arguments
data contains the defining data of the entity to be created.
The format of this list is similar to that returned by the entget function.
The entget function retrieves the defining data of an existing drawing entity and manipulates this entity data to create a new entity.
Also, in certain situations a technique may be applicable, where the entity whose defining data have been retrieved by the entget function is deleted and then restored as a drawing entity equivalent in entity type but modified in its geometric or property parameters by using the entmake function.
But in this case the entity reference (handles) and the database address (entity name) has changed although the visual representation of the entity in the graphic window(s) can be the same as before. The entmake function tests the validity of the values supplied for Layer name, Color, Linetype and TextStyle before the entity is generated:
- If the layer name supplied is not found in the layer table of the current drawing, entmake creates that new layer using the default values of Layer 0.
- An invalid Color value results in the function returning nil.
- A LineStyle or a TextStyle not yet defined in the corresponding table of the current database results in the function returning nil.
The type of the entity must be specified in the first or second element of the list. If the type is specified in the second buffer, the first buffer may contain only the entity name, which is ignored. If an entity reference (handle) is found in the list, it is ignored. The system automatically generates a new handle for the new drawing entity.
If an entity name (group code -1) is found in the list, it is ignored. The system generates a new Entity Name for the new entity.
Creating Complex Objects
Complex objects (PolyLines, Block definitions, Attributes of block insertions) are created by multiple calls of entmake. The first call generates the base element (POLYLINE, BLOCK, or INSERT). The function recognizes that a complex object is affected and stores the current data contents and the following data functions temporarily. The following calls of the entmake function will define the sub-elements (vertices in POLYLINEs, Attributes in BLOCK insertions, and entities defining a BLOCK). The sub-elements are temporarily added up, until the entmake function makes a statement indicating definition termination of a complex drawing object. This indication is done by specifying a ENDBLK "entity" (when defining a BLOCK) or a SEQEND "entity" (when defining a POLYLINE or an INSERT that generates a BLOCK insertion).
The definition of a complex drawing object may be canceled by entering entmake with no arguments. The temporary stored object is then refused.
If an error occurs during the generation of a sub-entity, the sub-entity is refused, but the entities generated so far remain. This allows error handling by the developer.
Anonymous Definitions
The BLOCK definition table of the drawing database may contain anonymous blocks. Cross-hatchings and dimensions are anonymous blocks. The user cannot use anonymous blocks directly (for example in the Insert command), because the block names are unknown to the user. Lisp allows access to anonymous blocks.
Anonymous blocks are created by dimensioning and hatch commands. The application developer can generate anonymous blocks with the entmake function.
An anonymous block created with entmake has a block name like *Uxxxxxx, where the first two characters mark the block as created by entmake. The following characters contain a unique number to identify the block. This block number is only valid during the current work session. If the drawing is reopened, a new number for the anonymous block is generated.
entmake recognizes automatically that an anonymous block has to be created, if the block name (group 2) is "*U". entmake adds a unique identifier to the internal block name. Furthermore, entmake sets the flag "Block type" (group 70) in the block definition.
Return Value
If the function succeeds, it returns the list containing the entity definition data; otherwise, the function returns nil.
: (entmake '((0 . "LINE")(10 0.0 0.0 0.0)(11 10.0 10.0 0.0)))
In the example above, group code 10 specifies the start point, and group code 11 the end point of a Line entity.